binutils-gdb/gdbserver/linux-low.cc

7254 lines
192 KiB
C++
Raw Permalink Normal View History

/* Low level interface to ptrace, for the remote server for GDB.
Copyright (C) 1995-2020 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "server.h"
#include "linux-low.h"
Move shared native target specific code to gdb/nat https://sourceware.org/gdb/wiki/Common describes the following directory structure: gdb/nat/ Native target backend files. Code that interfaces with the host debug API. E.g., ptrace code, Windows debug API code, procfs code should go here. gdb/target/ Host-independent, target vector specific code (target_ops). gdb/common/ All other shared code. This commit moves all native target backend files currently in gdb/common to gdb/nat. gdb/ 2014-06-20 Gary Benson <gbenson@redhat.com> * common/gdb_thread_db.h: Moved to nat. All includes updated. * common/glibc_thread_db.h: Likewise. * common/i386-cpuid.h: Likewise. * common/i386-gcc-cpuid.h: Likewise. * common/linux-btrace.h: Likewise. * common/linux-osdata.h: Likewise. * common/linux-procfs.h: Likewise. * common/linux-ptrace.h: Likewise. * common/mips-linux-watch.h: Likewise. * common/linux-btrace.c: Moved to nat. * common/linux-osdata.c: Likewise. * common/linux-procfs.c: Likewise. * common/linux-ptrace.c: Likewise. * common/mips-linux-watch.c: Likewise. * nat/gdb_thread_db.h: Moved from common. * nat/glibc_thread_db.h: Likewise. * nat/i386-cpuid.h: Likewise. * nat/i386-gcc-cpuid.h: Likewise. * nat/linux-btrace.c: Likewise. * nat/linux-btrace.h: Likewise. * nat/linux-osdata.c: Likewise. * nat/linux-osdata.h: Likewise. * nat/linux-procfs.c: Likewise. * nat/linux-procfs.h: Likewise. * nat/linux-ptrace.c: Likewise. * nat/linux-ptrace.h: Likewise. * nat/mips-linux-watch.c: Likewise. * nat/mips-linux-watch.h: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Reflect new locations. (object file files): Reordered. * gdb/copyright.py (EXCLUDE_LIST): Reflect new location of glibc_thread_db.h. gdb/gdbserver/ 2014-06-20 Gary Benson <gbenson@redhat.com> * Makefile.in (SFILES): Update locations for files moved from common to nat. (object file files): Reordered. gdb/testsuite/ 2014-06-20 Gary Benson <gbenson@redhat.com> * gdb.arch/i386-avx.exp: Fix include file location. * gdb.arch/i386-sse.exp: Likewise.
2014-06-19 15:46:38 +02:00
#include "nat/linux-osdata.h"
Rename common to gdbsupport This is the next patch in the ongoing series to move gdbsever to the top level. This patch just renames the "common" directory. The idea is to do this move in two parts: first rename the directory (this patch), then move the directory to the top. This approach makes the patches a bit more tractable. I chose the name "gdbsupport" for the directory. However, as this patch was largely written by sed, we could pick a new name without too much difficulty. Tested by the buildbot. gdb/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * contrib/ari/gdb_ari.sh: Change common to gdbsupport. * configure: Rebuild. * configure.ac: Change common to gdbsupport. * gdbsupport: Rename from common. * acinclude.m4: Change common to gdbsupport. * Makefile.in (CONFIG_SRC_SUBDIR, COMMON_SFILES) (HFILES_NO_SRCDIR, stamp-version, ALLDEPFILES): Change common to gdbsupport. * aarch64-tdep.c, ada-lang.c, ada-lang.h, agent.c, alloc.c, amd64-darwin-tdep.c, amd64-dicos-tdep.c, amd64-fbsd-nat.c, amd64-fbsd-tdep.c, amd64-linux-nat.c, amd64-linux-tdep.c, amd64-nbsd-tdep.c, amd64-obsd-tdep.c, amd64-sol2-tdep.c, amd64-tdep.c, amd64-windows-tdep.c, arch-utils.c, arch/aarch64-insn.c, arch/aarch64.c, arch/aarch64.h, arch/amd64.c, arch/amd64.h, arch/arm-get-next-pcs.c, arch/arm-linux.c, arch/arm.c, arch/i386.c, arch/i386.h, arch/ppc-linux-common.c, arch/riscv.c, arch/riscv.h, arch/tic6x.c, arm-tdep.c, auto-load.c, auxv.c, ax-gdb.c, ax-general.c, ax.h, breakpoint.c, breakpoint.h, btrace.c, btrace.h, build-id.c, build-id.h, c-lang.h, charset.c, charset.h, cli/cli-cmds.c, cli/cli-cmds.h, cli/cli-decode.c, cli/cli-dump.c, cli/cli-option.h, cli/cli-script.c, coff-pe-read.c, command.h, compile/compile-c-support.c, compile/compile-c.h, compile/compile-cplus-symbols.c, compile/compile-cplus-types.c, compile/compile-cplus.h, compile/compile-loc2c.c, compile/compile.c, completer.c, completer.h, contrib/ari/gdb_ari.sh, corefile.c, corelow.c, cp-support.c, cp-support.h, cp-valprint.c, csky-tdep.c, ctf.c, darwin-nat.c, debug.c, defs.h, disasm-selftests.c, disasm.c, disasm.h, dtrace-probe.c, dwarf-index-cache.c, dwarf-index-cache.h, dwarf-index-write.c, dwarf2-frame.c, dwarf2expr.c, dwarf2loc.c, dwarf2read.c, event-loop.c, event-top.c, exceptions.c, exec.c, extension.h, fbsd-nat.c, features/aarch64-core.c, features/aarch64-fpu.c, features/aarch64-pauth.c, features/aarch64-sve.c, features/i386/32bit-avx.c, features/i386/32bit-avx512.c, features/i386/32bit-core.c, features/i386/32bit-linux.c, features/i386/32bit-mpx.c, features/i386/32bit-pkeys.c, features/i386/32bit-segments.c, features/i386/32bit-sse.c, features/i386/64bit-avx.c, features/i386/64bit-avx512.c, features/i386/64bit-core.c, features/i386/64bit-linux.c, features/i386/64bit-mpx.c, features/i386/64bit-pkeys.c, features/i386/64bit-segments.c, features/i386/64bit-sse.c, features/i386/x32-core.c, features/riscv/32bit-cpu.c, features/riscv/32bit-csr.c, features/riscv/32bit-fpu.c, features/riscv/64bit-cpu.c, features/riscv/64bit-csr.c, features/riscv/64bit-fpu.c, features/tic6x-c6xp.c, features/tic6x-core.c, features/tic6x-gp.c, filename-seen-cache.h, findcmd.c, findvar.c, fork-child.c, gcore.c, gdb_bfd.c, gdb_bfd.h, gdb_proc_service.h, gdb_regex.c, gdb_select.h, gdb_usleep.c, gdbarch-selftests.c, gdbthread.h, gdbtypes.h, gnu-nat.c, go32-nat.c, guile/guile.c, guile/scm-ports.c, guile/scm-safe-call.c, guile/scm-type.c, i386-fbsd-nat.c, i386-fbsd-tdep.c, i386-go32-tdep.c, i386-linux-nat.c, i386-linux-tdep.c, i386-tdep.c, i387-tdep.c, ia64-libunwind-tdep.c, ia64-linux-nat.c, inf-child.c, inf-ptrace.c, infcall.c, infcall.h, infcmd.c, inferior-iter.h, inferior.c, inferior.h, inflow.c, inflow.h, infrun.c, infrun.h, inline-frame.c, language.h, linespec.c, linux-fork.c, linux-nat.c, linux-tdep.c, linux-thread-db.c, location.c, machoread.c, macrotab.h, main.c, maint.c, maint.h, memattr.c, memrange.h, mi/mi-cmd-break.h, mi/mi-cmd-env.c, mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-interp.c, mi/mi-main.c, mi/mi-parse.h, minsyms.c, mips-linux-tdep.c, namespace.h, nat/aarch64-linux-hw-point.c, nat/aarch64-linux-hw-point.h, nat/aarch64-linux.c, nat/aarch64-sve-linux-ptrace.c, nat/amd64-linux-siginfo.c, nat/fork-inferior.c, nat/linux-btrace.c, nat/linux-btrace.h, nat/linux-namespaces.c, nat/linux-nat.h, nat/linux-osdata.c, nat/linux-personality.c, nat/linux-procfs.c, nat/linux-ptrace.c, nat/linux-ptrace.h, nat/linux-waitpid.c, nat/mips-linux-watch.c, nat/mips-linux-watch.h, nat/ppc-linux.c, nat/x86-dregs.c, nat/x86-dregs.h, nat/x86-linux-dregs.c, nat/x86-linux.c, nto-procfs.c, nto-tdep.c, objfile-flags.h, objfiles.c, objfiles.h, obsd-nat.c, observable.h, osdata.c, p-valprint.c, parse.c, parser-defs.h, ppc-linux-nat.c, printcmd.c, probe.c, proc-api.c, procfs.c, producer.c, progspace.h, psymtab.h, python/py-framefilter.c, python/py-inferior.c, python/py-ref.h, python/py-type.c, python/python.c, record-btrace.c, record-full.c, record.c, record.h, regcache-dump.c, regcache.c, regcache.h, remote-fileio.c, remote-fileio.h, remote-sim.c, remote.c, riscv-tdep.c, rs6000-aix-tdep.c, rust-exp.y, s12z-tdep.c, selftest-arch.c, ser-base.c, ser-event.c, ser-pipe.c, ser-tcp.c, ser-unix.c, skip.c, solib-aix.c, solib-target.c, solib.c, source-cache.c, source.c, source.h, sparc-nat.c, spu-linux-nat.c, stack.c, stap-probe.c, symfile-add-flags.h, symfile.c, symfile.h, symtab.c, symtab.h, target-descriptions.c, target-descriptions.h, target-memory.c, target.c, target.h, target/waitstatus.c, target/waitstatus.h, thread-iter.h, thread.c, tilegx-tdep.c, top.c, top.h, tracefile-tfile.c, tracefile.c, tracepoint.c, tracepoint.h, tui/tui-io.c, ui-file.c, ui-out.h, unittests/array-view-selftests.c, unittests/child-path-selftests.c, unittests/cli-utils-selftests.c, unittests/common-utils-selftests.c, unittests/copy_bitwise-selftests.c, unittests/environ-selftests.c, unittests/format_pieces-selftests.c, unittests/function-view-selftests.c, unittests/lookup_name_info-selftests.c, unittests/memory-map-selftests.c, unittests/memrange-selftests.c, unittests/mkdir-recursive-selftests.c, unittests/observable-selftests.c, unittests/offset-type-selftests.c, unittests/optional-selftests.c, unittests/parse-connection-spec-selftests.c, unittests/ptid-selftests.c, unittests/rsp-low-selftests.c, unittests/scoped_fd-selftests.c, unittests/scoped_mmap-selftests.c, unittests/scoped_restore-selftests.c, unittests/string_view-selftests.c, unittests/style-selftests.c, unittests/tracepoint-selftests.c, unittests/unpack-selftests.c, unittests/utils-selftests.c, unittests/xml-utils-selftests.c, utils.c, utils.h, valarith.c, valops.c, valprint.c, value.c, value.h, varobj.c, varobj.h, windows-nat.c, x86-linux-nat.c, xml-support.c, xml-support.h, xml-tdesc.h, xstormy16-tdep.c, xtensa-linux-nat.c, dwarf2read.h: Change common to gdbsupport. gdb/gdbserver/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * configure: Rebuild. * configure.ac: Change common to gdbsupport. * acinclude.m4: Change common to gdbsupport. * Makefile.in (SFILES, OBS, GDBREPLAY_OBS, IPA_OBJS) (version-generated.c, gdbsupport/%-ipa.o, gdbsupport/%.o): Change common to gdbsupport. * ax.c, event-loop.c, fork-child.c, gdb_proc_service.h, gdbreplay.c, gdbthread.h, hostio-errno.c, hostio.c, i387-fp.c, inferiors.c, inferiors.h, linux-aarch64-tdesc-selftest.c, linux-amd64-ipa.c, linux-i386-ipa.c, linux-low.c, linux-tic6x-low.c, linux-x86-low.c, linux-x86-tdesc-selftest.c, linux-x86-tdesc.c, lynx-i386-low.c, lynx-low.c, mem-break.h, nto-x86-low.c, regcache.c, regcache.h, remote-utils.c, server.c, server.h, spu-low.c, symbol.c, target.h, tdesc.c, tdesc.h, thread-db.c, tracepoint.c, win32-i386-low.c, win32-low.c: Change common to gdbsupport.
2019-05-06 04:29:24 +02:00
#include "gdbsupport/agent.h"
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
#include "tdesc.h"
Rename common to gdbsupport This is the next patch in the ongoing series to move gdbsever to the top level. This patch just renames the "common" directory. The idea is to do this move in two parts: first rename the directory (this patch), then move the directory to the top. This approach makes the patches a bit more tractable. I chose the name "gdbsupport" for the directory. However, as this patch was largely written by sed, we could pick a new name without too much difficulty. Tested by the buildbot. gdb/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * contrib/ari/gdb_ari.sh: Change common to gdbsupport. * configure: Rebuild. * configure.ac: Change common to gdbsupport. * gdbsupport: Rename from common. * acinclude.m4: Change common to gdbsupport. * Makefile.in (CONFIG_SRC_SUBDIR, COMMON_SFILES) (HFILES_NO_SRCDIR, stamp-version, ALLDEPFILES): Change common to gdbsupport. * aarch64-tdep.c, ada-lang.c, ada-lang.h, agent.c, alloc.c, amd64-darwin-tdep.c, amd64-dicos-tdep.c, amd64-fbsd-nat.c, amd64-fbsd-tdep.c, amd64-linux-nat.c, amd64-linux-tdep.c, amd64-nbsd-tdep.c, amd64-obsd-tdep.c, amd64-sol2-tdep.c, amd64-tdep.c, amd64-windows-tdep.c, arch-utils.c, arch/aarch64-insn.c, arch/aarch64.c, arch/aarch64.h, arch/amd64.c, arch/amd64.h, arch/arm-get-next-pcs.c, arch/arm-linux.c, arch/arm.c, arch/i386.c, arch/i386.h, arch/ppc-linux-common.c, arch/riscv.c, arch/riscv.h, arch/tic6x.c, arm-tdep.c, auto-load.c, auxv.c, ax-gdb.c, ax-general.c, ax.h, breakpoint.c, breakpoint.h, btrace.c, btrace.h, build-id.c, build-id.h, c-lang.h, charset.c, charset.h, cli/cli-cmds.c, cli/cli-cmds.h, cli/cli-decode.c, cli/cli-dump.c, cli/cli-option.h, cli/cli-script.c, coff-pe-read.c, command.h, compile/compile-c-support.c, compile/compile-c.h, compile/compile-cplus-symbols.c, compile/compile-cplus-types.c, compile/compile-cplus.h, compile/compile-loc2c.c, compile/compile.c, completer.c, completer.h, contrib/ari/gdb_ari.sh, corefile.c, corelow.c, cp-support.c, cp-support.h, cp-valprint.c, csky-tdep.c, ctf.c, darwin-nat.c, debug.c, defs.h, disasm-selftests.c, disasm.c, disasm.h, dtrace-probe.c, dwarf-index-cache.c, dwarf-index-cache.h, dwarf-index-write.c, dwarf2-frame.c, dwarf2expr.c, dwarf2loc.c, dwarf2read.c, event-loop.c, event-top.c, exceptions.c, exec.c, extension.h, fbsd-nat.c, features/aarch64-core.c, features/aarch64-fpu.c, features/aarch64-pauth.c, features/aarch64-sve.c, features/i386/32bit-avx.c, features/i386/32bit-avx512.c, features/i386/32bit-core.c, features/i386/32bit-linux.c, features/i386/32bit-mpx.c, features/i386/32bit-pkeys.c, features/i386/32bit-segments.c, features/i386/32bit-sse.c, features/i386/64bit-avx.c, features/i386/64bit-avx512.c, features/i386/64bit-core.c, features/i386/64bit-linux.c, features/i386/64bit-mpx.c, features/i386/64bit-pkeys.c, features/i386/64bit-segments.c, features/i386/64bit-sse.c, features/i386/x32-core.c, features/riscv/32bit-cpu.c, features/riscv/32bit-csr.c, features/riscv/32bit-fpu.c, features/riscv/64bit-cpu.c, features/riscv/64bit-csr.c, features/riscv/64bit-fpu.c, features/tic6x-c6xp.c, features/tic6x-core.c, features/tic6x-gp.c, filename-seen-cache.h, findcmd.c, findvar.c, fork-child.c, gcore.c, gdb_bfd.c, gdb_bfd.h, gdb_proc_service.h, gdb_regex.c, gdb_select.h, gdb_usleep.c, gdbarch-selftests.c, gdbthread.h, gdbtypes.h, gnu-nat.c, go32-nat.c, guile/guile.c, guile/scm-ports.c, guile/scm-safe-call.c, guile/scm-type.c, i386-fbsd-nat.c, i386-fbsd-tdep.c, i386-go32-tdep.c, i386-linux-nat.c, i386-linux-tdep.c, i386-tdep.c, i387-tdep.c, ia64-libunwind-tdep.c, ia64-linux-nat.c, inf-child.c, inf-ptrace.c, infcall.c, infcall.h, infcmd.c, inferior-iter.h, inferior.c, inferior.h, inflow.c, inflow.h, infrun.c, infrun.h, inline-frame.c, language.h, linespec.c, linux-fork.c, linux-nat.c, linux-tdep.c, linux-thread-db.c, location.c, machoread.c, macrotab.h, main.c, maint.c, maint.h, memattr.c, memrange.h, mi/mi-cmd-break.h, mi/mi-cmd-env.c, mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-interp.c, mi/mi-main.c, mi/mi-parse.h, minsyms.c, mips-linux-tdep.c, namespace.h, nat/aarch64-linux-hw-point.c, nat/aarch64-linux-hw-point.h, nat/aarch64-linux.c, nat/aarch64-sve-linux-ptrace.c, nat/amd64-linux-siginfo.c, nat/fork-inferior.c, nat/linux-btrace.c, nat/linux-btrace.h, nat/linux-namespaces.c, nat/linux-nat.h, nat/linux-osdata.c, nat/linux-personality.c, nat/linux-procfs.c, nat/linux-ptrace.c, nat/linux-ptrace.h, nat/linux-waitpid.c, nat/mips-linux-watch.c, nat/mips-linux-watch.h, nat/ppc-linux.c, nat/x86-dregs.c, nat/x86-dregs.h, nat/x86-linux-dregs.c, nat/x86-linux.c, nto-procfs.c, nto-tdep.c, objfile-flags.h, objfiles.c, objfiles.h, obsd-nat.c, observable.h, osdata.c, p-valprint.c, parse.c, parser-defs.h, ppc-linux-nat.c, printcmd.c, probe.c, proc-api.c, procfs.c, producer.c, progspace.h, psymtab.h, python/py-framefilter.c, python/py-inferior.c, python/py-ref.h, python/py-type.c, python/python.c, record-btrace.c, record-full.c, record.c, record.h, regcache-dump.c, regcache.c, regcache.h, remote-fileio.c, remote-fileio.h, remote-sim.c, remote.c, riscv-tdep.c, rs6000-aix-tdep.c, rust-exp.y, s12z-tdep.c, selftest-arch.c, ser-base.c, ser-event.c, ser-pipe.c, ser-tcp.c, ser-unix.c, skip.c, solib-aix.c, solib-target.c, solib.c, source-cache.c, source.c, source.h, sparc-nat.c, spu-linux-nat.c, stack.c, stap-probe.c, symfile-add-flags.h, symfile.c, symfile.h, symtab.c, symtab.h, target-descriptions.c, target-descriptions.h, target-memory.c, target.c, target.h, target/waitstatus.c, target/waitstatus.h, thread-iter.h, thread.c, tilegx-tdep.c, top.c, top.h, tracefile-tfile.c, tracefile.c, tracepoint.c, tracepoint.h, tui/tui-io.c, ui-file.c, ui-out.h, unittests/array-view-selftests.c, unittests/child-path-selftests.c, unittests/cli-utils-selftests.c, unittests/common-utils-selftests.c, unittests/copy_bitwise-selftests.c, unittests/environ-selftests.c, unittests/format_pieces-selftests.c, unittests/function-view-selftests.c, unittests/lookup_name_info-selftests.c, unittests/memory-map-selftests.c, unittests/memrange-selftests.c, unittests/mkdir-recursive-selftests.c, unittests/observable-selftests.c, unittests/offset-type-selftests.c, unittests/optional-selftests.c, unittests/parse-connection-spec-selftests.c, unittests/ptid-selftests.c, unittests/rsp-low-selftests.c, unittests/scoped_fd-selftests.c, unittests/scoped_mmap-selftests.c, unittests/scoped_restore-selftests.c, unittests/string_view-selftests.c, unittests/style-selftests.c, unittests/tracepoint-selftests.c, unittests/unpack-selftests.c, unittests/utils-selftests.c, unittests/xml-utils-selftests.c, utils.c, utils.h, valarith.c, valops.c, valprint.c, value.c, value.h, varobj.c, varobj.h, windows-nat.c, x86-linux-nat.c, xml-support.c, xml-support.h, xml-tdesc.h, xstormy16-tdep.c, xtensa-linux-nat.c, dwarf2read.h: Change common to gdbsupport. gdb/gdbserver/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * configure: Rebuild. * configure.ac: Change common to gdbsupport. * acinclude.m4: Change common to gdbsupport. * Makefile.in (SFILES, OBS, GDBREPLAY_OBS, IPA_OBJS) (version-generated.c, gdbsupport/%-ipa.o, gdbsupport/%.o): Change common to gdbsupport. * ax.c, event-loop.c, fork-child.c, gdb_proc_service.h, gdbreplay.c, gdbthread.h, hostio-errno.c, hostio.c, i387-fp.c, inferiors.c, inferiors.h, linux-aarch64-tdesc-selftest.c, linux-amd64-ipa.c, linux-i386-ipa.c, linux-low.c, linux-tic6x-low.c, linux-x86-low.c, linux-x86-tdesc-selftest.c, linux-x86-tdesc.c, lynx-i386-low.c, lynx-low.c, mem-break.h, nto-x86-low.c, regcache.c, regcache.h, remote-utils.c, server.c, server.h, spu-low.c, symbol.c, target.h, tdesc.c, tdesc.h, thread-db.c, tracepoint.c, win32-i386-low.c, win32-low.c: Change common to gdbsupport.
2019-05-06 04:29:24 +02:00
#include "gdbsupport/rsp-low.h"
#include "gdbsupport/signals-state-save-restore.h"
Unify ptrace options discovery code and make both GDB and gdbserver use it. gdb/ * Makefile.in (HFILES_NO_SRCDIR): Add nat/linux-nat.h and nat/linux-waitpid.h. (linux-waitpid.o): New object file rule. * common/linux-ptrace.c: Include nat/linux-waitpid.h. (current_ptrace_options): Moved from linux-nat.c. (linux_ptrace_test_ret_to_nx): Use type casts for ptrace parameters. (linux_fork_to_function): New function. (linux_grandchild_function): Likewise. (linux_child_function): Likewise. (linux_check_ptrace_features): New function, heavily based on linux-nat.c:linux_test_for_tracefork. (linux_enable_event_reporting): New function. (ptrace_supports_feature): Likewise. (linux_supports_tracefork): Likewise. (linux_supports_traceclone): Likewise. (linux_supports_tracevforkdone): Likewise. (linux_supports_tracesysgood): Likewise. * common/linux-ptrace.h (HAS_NOMMU): Moved from gdbserver/linux-low.c. (linux_enable_event_reporting): New declaration. (linux_supports_tracefork): Likewise. (linux_supports_traceclone): Likewise. (linux_supports_tracevforkdone): Likewise. (linux_supports_tracesysgood): Likewise. * config.in (PTRACE_TYPE_ARG4): Regenerate. * config/aarch64/linux.mh (NATDEPFILES): Add linux-waitpid.o. * config/alpha/alpha-linux.mh (NATDEPFILES): Likewise. * config/arm/linux.mh (NATDEPFILES): Likewise. * config/i386/linux.mh (NATDEPFILES): Likewise. * config/i386/linux64.mh (NATDEPFILES): Likewise. * config/ia64/linux.mh (NATDEPFILES): Likewise. * config/m32r/linux.mh (NATDEPFILES): Likewise. * config/m68k/linux.mh (NATDEPFILES): Likewise. * config/mips/linux.mh (NATDEPFILES): Likewise. * config/pa/linux.mh (NATDEPFILES): Likewise.. * config/powerpc/linux.mh (NATDEPFILES): Likewise.. * config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise. * config/powerpc/spu-linux.mh (NATDEPFILES): Likewise. * config/sparc/linux.mh (NATDEPFILES): Likewise. * config/sparc/linux64.mh (NATDEPFILES): Likewise. * config/tilegx/linux.mh (NATDEPFILES): Likewise. * config/xtensa/linux.mh (NATDEPFILES): Likewise. * configure.ac (AC_CACHE_CHECK): Add void * to the list of ptrace's 4th argument's types. Check the type of PTRACE_TYPE_ARG4. * configure: Regenerate. * linux-nat.c: Include nat/linux-nat.h and nat/linux-waitpid.h. (SYSCALL_SIGTRAP): Moved to nat/linux-nat.h. (linux_supports_tracefork_flag): Remove. (linux_supports_tracesysgood_flag): Likewise. (linux_supports_tracevforkdone_flag): Likewise. (current_ptrace_options): Moved to common/linux-ptrace.c. (linux_tracefork_child): Remove. (my_waitpid): Remove. (linux_test_for_tracefork): Renamed to linux_check_ptrace_features and moved to common/linux-ptrace.c. (linux_test_for_tracesysgood): Remove. (linux_supports_tracesysgood): Remove. (linux_supports_tracefork): Remove. (linux_supports_tracevforkdone): Remove. (linux_enable_tracesysgood): Remove. (linux_enable_event_reporting): Remove. (linux_init_ptrace): New function. (linux_child_post_attach): Call linux_init_ptrace. (linux_child_post_startup_inferior): Call linux_init_ptrace. (linux_child_follow_fork): Call linux_supports_tracefork and linux_supports_tracevforkdone. (linux_child_insert_fork_catchpoint): Call linux_supports_tracefork. (linux_child_insert_vfork_catchpoint): Likewise. (linux_child_set_syscall_catchpoint): Call linux_supports_tracesysgood. (lin_lwp_attach_lwp): Call linux_supports_tracefork. * nat/linux-nat.h: New file. * nat/linux-waitpid.c: New file. * nat/linux-waitpid.h: New file. gdb/gdbserver/ * Makefile.in: Explain why ../target and ../nat are not listed as include file search paths. (linux-waitpid.o): New object file rule. * configure.srv (srv_native_linux_obj): New variable. Replace all occurrences of linux native object files with $srv_native_linux_obj. * linux-low.c: Include nat/linux-nat.h and nat/linux-waitpid.h. (HAS_NOMMU): Move defining logic to common/linux-ptrace.c. (linux_enable_event_reporting): Remove declaration. (my_waitpid): Moved to common/linux-waitpid.c. (linux_wait_for_event): Pass ptid when calling linux_enable_event_reporting. (linux_supports_tracefork_flag): Remove. (linux_enable_event_reporting): Likewise. (linux_tracefork_grandchild): Remove. (STACK_SIZE): Moved to common/linux-ptrace.c. (linux_tracefork_child): Remove. (linux_test_for_tracefork): Remove. (linux_look_up_symbols): Call linux_supports_traceclone. (initialize_low): Remove call to linux_test_for_tracefork. * linux-low.h (PTRACE_TYPE_ARG3): Move to common/linux-ptrace.h. (PTRACE_TYPE_ARG4): Likewise. Include linux-ptrace.h.
2013-08-23 01:46:30 +02:00
#include "nat/linux-nat.h"
#include "nat/linux-waitpid.h"
Rename common to gdbsupport This is the next patch in the ongoing series to move gdbsever to the top level. This patch just renames the "common" directory. The idea is to do this move in two parts: first rename the directory (this patch), then move the directory to the top. This approach makes the patches a bit more tractable. I chose the name "gdbsupport" for the directory. However, as this patch was largely written by sed, we could pick a new name without too much difficulty. Tested by the buildbot. gdb/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * contrib/ari/gdb_ari.sh: Change common to gdbsupport. * configure: Rebuild. * configure.ac: Change common to gdbsupport. * gdbsupport: Rename from common. * acinclude.m4: Change common to gdbsupport. * Makefile.in (CONFIG_SRC_SUBDIR, COMMON_SFILES) (HFILES_NO_SRCDIR, stamp-version, ALLDEPFILES): Change common to gdbsupport. * aarch64-tdep.c, ada-lang.c, ada-lang.h, agent.c, alloc.c, amd64-darwin-tdep.c, amd64-dicos-tdep.c, amd64-fbsd-nat.c, amd64-fbsd-tdep.c, amd64-linux-nat.c, amd64-linux-tdep.c, amd64-nbsd-tdep.c, amd64-obsd-tdep.c, amd64-sol2-tdep.c, amd64-tdep.c, amd64-windows-tdep.c, arch-utils.c, arch/aarch64-insn.c, arch/aarch64.c, arch/aarch64.h, arch/amd64.c, arch/amd64.h, arch/arm-get-next-pcs.c, arch/arm-linux.c, arch/arm.c, arch/i386.c, arch/i386.h, arch/ppc-linux-common.c, arch/riscv.c, arch/riscv.h, arch/tic6x.c, arm-tdep.c, auto-load.c, auxv.c, ax-gdb.c, ax-general.c, ax.h, breakpoint.c, breakpoint.h, btrace.c, btrace.h, build-id.c, build-id.h, c-lang.h, charset.c, charset.h, cli/cli-cmds.c, cli/cli-cmds.h, cli/cli-decode.c, cli/cli-dump.c, cli/cli-option.h, cli/cli-script.c, coff-pe-read.c, command.h, compile/compile-c-support.c, compile/compile-c.h, compile/compile-cplus-symbols.c, compile/compile-cplus-types.c, compile/compile-cplus.h, compile/compile-loc2c.c, compile/compile.c, completer.c, completer.h, contrib/ari/gdb_ari.sh, corefile.c, corelow.c, cp-support.c, cp-support.h, cp-valprint.c, csky-tdep.c, ctf.c, darwin-nat.c, debug.c, defs.h, disasm-selftests.c, disasm.c, disasm.h, dtrace-probe.c, dwarf-index-cache.c, dwarf-index-cache.h, dwarf-index-write.c, dwarf2-frame.c, dwarf2expr.c, dwarf2loc.c, dwarf2read.c, event-loop.c, event-top.c, exceptions.c, exec.c, extension.h, fbsd-nat.c, features/aarch64-core.c, features/aarch64-fpu.c, features/aarch64-pauth.c, features/aarch64-sve.c, features/i386/32bit-avx.c, features/i386/32bit-avx512.c, features/i386/32bit-core.c, features/i386/32bit-linux.c, features/i386/32bit-mpx.c, features/i386/32bit-pkeys.c, features/i386/32bit-segments.c, features/i386/32bit-sse.c, features/i386/64bit-avx.c, features/i386/64bit-avx512.c, features/i386/64bit-core.c, features/i386/64bit-linux.c, features/i386/64bit-mpx.c, features/i386/64bit-pkeys.c, features/i386/64bit-segments.c, features/i386/64bit-sse.c, features/i386/x32-core.c, features/riscv/32bit-cpu.c, features/riscv/32bit-csr.c, features/riscv/32bit-fpu.c, features/riscv/64bit-cpu.c, features/riscv/64bit-csr.c, features/riscv/64bit-fpu.c, features/tic6x-c6xp.c, features/tic6x-core.c, features/tic6x-gp.c, filename-seen-cache.h, findcmd.c, findvar.c, fork-child.c, gcore.c, gdb_bfd.c, gdb_bfd.h, gdb_proc_service.h, gdb_regex.c, gdb_select.h, gdb_usleep.c, gdbarch-selftests.c, gdbthread.h, gdbtypes.h, gnu-nat.c, go32-nat.c, guile/guile.c, guile/scm-ports.c, guile/scm-safe-call.c, guile/scm-type.c, i386-fbsd-nat.c, i386-fbsd-tdep.c, i386-go32-tdep.c, i386-linux-nat.c, i386-linux-tdep.c, i386-tdep.c, i387-tdep.c, ia64-libunwind-tdep.c, ia64-linux-nat.c, inf-child.c, inf-ptrace.c, infcall.c, infcall.h, infcmd.c, inferior-iter.h, inferior.c, inferior.h, inflow.c, inflow.h, infrun.c, infrun.h, inline-frame.c, language.h, linespec.c, linux-fork.c, linux-nat.c, linux-tdep.c, linux-thread-db.c, location.c, machoread.c, macrotab.h, main.c, maint.c, maint.h, memattr.c, memrange.h, mi/mi-cmd-break.h, mi/mi-cmd-env.c, mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-interp.c, mi/mi-main.c, mi/mi-parse.h, minsyms.c, mips-linux-tdep.c, namespace.h, nat/aarch64-linux-hw-point.c, nat/aarch64-linux-hw-point.h, nat/aarch64-linux.c, nat/aarch64-sve-linux-ptrace.c, nat/amd64-linux-siginfo.c, nat/fork-inferior.c, nat/linux-btrace.c, nat/linux-btrace.h, nat/linux-namespaces.c, nat/linux-nat.h, nat/linux-osdata.c, nat/linux-personality.c, nat/linux-procfs.c, nat/linux-ptrace.c, nat/linux-ptrace.h, nat/linux-waitpid.c, nat/mips-linux-watch.c, nat/mips-linux-watch.h, nat/ppc-linux.c, nat/x86-dregs.c, nat/x86-dregs.h, nat/x86-linux-dregs.c, nat/x86-linux.c, nto-procfs.c, nto-tdep.c, objfile-flags.h, objfiles.c, objfiles.h, obsd-nat.c, observable.h, osdata.c, p-valprint.c, parse.c, parser-defs.h, ppc-linux-nat.c, printcmd.c, probe.c, proc-api.c, procfs.c, producer.c, progspace.h, psymtab.h, python/py-framefilter.c, python/py-inferior.c, python/py-ref.h, python/py-type.c, python/python.c, record-btrace.c, record-full.c, record.c, record.h, regcache-dump.c, regcache.c, regcache.h, remote-fileio.c, remote-fileio.h, remote-sim.c, remote.c, riscv-tdep.c, rs6000-aix-tdep.c, rust-exp.y, s12z-tdep.c, selftest-arch.c, ser-base.c, ser-event.c, ser-pipe.c, ser-tcp.c, ser-unix.c, skip.c, solib-aix.c, solib-target.c, solib.c, source-cache.c, source.c, source.h, sparc-nat.c, spu-linux-nat.c, stack.c, stap-probe.c, symfile-add-flags.h, symfile.c, symfile.h, symtab.c, symtab.h, target-descriptions.c, target-descriptions.h, target-memory.c, target.c, target.h, target/waitstatus.c, target/waitstatus.h, thread-iter.h, thread.c, tilegx-tdep.c, top.c, top.h, tracefile-tfile.c, tracefile.c, tracepoint.c, tracepoint.h, tui/tui-io.c, ui-file.c, ui-out.h, unittests/array-view-selftests.c, unittests/child-path-selftests.c, unittests/cli-utils-selftests.c, unittests/common-utils-selftests.c, unittests/copy_bitwise-selftests.c, unittests/environ-selftests.c, unittests/format_pieces-selftests.c, unittests/function-view-selftests.c, unittests/lookup_name_info-selftests.c, unittests/memory-map-selftests.c, unittests/memrange-selftests.c, unittests/mkdir-recursive-selftests.c, unittests/observable-selftests.c, unittests/offset-type-selftests.c, unittests/optional-selftests.c, unittests/parse-connection-spec-selftests.c, unittests/ptid-selftests.c, unittests/rsp-low-selftests.c, unittests/scoped_fd-selftests.c, unittests/scoped_mmap-selftests.c, unittests/scoped_restore-selftests.c, unittests/string_view-selftests.c, unittests/style-selftests.c, unittests/tracepoint-selftests.c, unittests/unpack-selftests.c, unittests/utils-selftests.c, unittests/xml-utils-selftests.c, utils.c, utils.h, valarith.c, valops.c, valprint.c, value.c, value.h, varobj.c, varobj.h, windows-nat.c, x86-linux-nat.c, xml-support.c, xml-support.h, xml-tdesc.h, xstormy16-tdep.c, xtensa-linux-nat.c, dwarf2read.h: Change common to gdbsupport. gdb/gdbserver/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * configure: Rebuild. * configure.ac: Change common to gdbsupport. * acinclude.m4: Change common to gdbsupport. * Makefile.in (SFILES, OBS, GDBREPLAY_OBS, IPA_OBJS) (version-generated.c, gdbsupport/%-ipa.o, gdbsupport/%.o): Change common to gdbsupport. * ax.c, event-loop.c, fork-child.c, gdb_proc_service.h, gdbreplay.c, gdbthread.h, hostio-errno.c, hostio.c, i387-fp.c, inferiors.c, inferiors.h, linux-aarch64-tdesc-selftest.c, linux-amd64-ipa.c, linux-i386-ipa.c, linux-low.c, linux-tic6x-low.c, linux-x86-low.c, linux-x86-tdesc-selftest.c, linux-x86-tdesc.c, lynx-i386-low.c, lynx-low.c, mem-break.h, nto-x86-low.c, regcache.c, regcache.h, remote-utils.c, server.c, server.h, spu-low.c, symbol.c, target.h, tdesc.c, tdesc.h, thread-db.c, tracepoint.c, win32-i386-low.c, win32-low.c: Change common to gdbsupport.
2019-05-06 04:29:24 +02:00
#include "gdbsupport/gdb_wait.h"
#include "nat/gdb_ptrace.h"
Move shared native target specific code to gdb/nat https://sourceware.org/gdb/wiki/Common describes the following directory structure: gdb/nat/ Native target backend files. Code that interfaces with the host debug API. E.g., ptrace code, Windows debug API code, procfs code should go here. gdb/target/ Host-independent, target vector specific code (target_ops). gdb/common/ All other shared code. This commit moves all native target backend files currently in gdb/common to gdb/nat. gdb/ 2014-06-20 Gary Benson <gbenson@redhat.com> * common/gdb_thread_db.h: Moved to nat. All includes updated. * common/glibc_thread_db.h: Likewise. * common/i386-cpuid.h: Likewise. * common/i386-gcc-cpuid.h: Likewise. * common/linux-btrace.h: Likewise. * common/linux-osdata.h: Likewise. * common/linux-procfs.h: Likewise. * common/linux-ptrace.h: Likewise. * common/mips-linux-watch.h: Likewise. * common/linux-btrace.c: Moved to nat. * common/linux-osdata.c: Likewise. * common/linux-procfs.c: Likewise. * common/linux-ptrace.c: Likewise. * common/mips-linux-watch.c: Likewise. * nat/gdb_thread_db.h: Moved from common. * nat/glibc_thread_db.h: Likewise. * nat/i386-cpuid.h: Likewise. * nat/i386-gcc-cpuid.h: Likewise. * nat/linux-btrace.c: Likewise. * nat/linux-btrace.h: Likewise. * nat/linux-osdata.c: Likewise. * nat/linux-osdata.h: Likewise. * nat/linux-procfs.c: Likewise. * nat/linux-procfs.h: Likewise. * nat/linux-ptrace.c: Likewise. * nat/linux-ptrace.h: Likewise. * nat/mips-linux-watch.c: Likewise. * nat/mips-linux-watch.h: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Reflect new locations. (object file files): Reordered. * gdb/copyright.py (EXCLUDE_LIST): Reflect new location of glibc_thread_db.h. gdb/gdbserver/ 2014-06-20 Gary Benson <gbenson@redhat.com> * Makefile.in (SFILES): Update locations for files moved from common to nat. (object file files): Reordered. gdb/testsuite/ 2014-06-20 Gary Benson <gbenson@redhat.com> * gdb.arch/i386-avx.exp: Fix include file location. * gdb.arch/i386-sse.exp: Likewise.
2014-06-19 15:46:38 +02:00
#include "nat/linux-ptrace.h"
#include "nat/linux-procfs.h"
Move code to disable ASR to nat/ This patch moves the shared code present on gdb/linux-nat.c:linux_nat_create_inferior and gdb/gdbserver/linux-low.c:linux_create_inferior to nat/linux-personality.c. This code is responsible for disabling address space randomization based on user setting, and using <sys/personality.h> to do that. I decided to put the prototype of the maybe_disable_address_space_randomization on nat/linux-osdata.h because it seemed the best place to put it. I regression-tested this patch on Fedora 20 x86_64, and found no regressions. gdb/ChangeLog 2015-01-15 Sergio Durigan Junior <sergiodj@redhat.com> * Makefile.in (HFILES_NO_SRCDIR): Add nat/linux-personality.h. (linux-personality.o): New rule. * common/common-defs.h: Include <stdint.h>. * config/aarch64/linux.mh (NATDEPFILES): Include linux-personality.o. * config/alpha/alpha-linux.mh (NATDEPFILES): Likewise. * config/arm/linux.mh (NATDEPFILES): Likewise. * config/i386/linux64.mh (NATDEPFILES): Likewise. * config/i386/linux.mh (NATDEPFILES): Likewise. * config/ia64/linux.mh (NATDEPFILES): Likewise. * config/m32r/linux.mh (NATDEPFILES): Likewise. * config/m68k/linux.mh (NATDEPFILES): Likewise. * config/mips/linux.mh (NATDEPFILES): Likewise. * config/pa/linux.mh (NATDEPFILES): Likewise. * config/powerpc/linux.mh (NATDEPFILES): Likewise. * config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise. * config/powerpc/spu-linux.mh (NATDEPFILES): Likewise. * config/s390/linux.mh (NATDEPFILES): Likewise. * config/sparc/linux64.mh (NATDEPFILES): Likewise. * config/sparc/linux.mh (NATDEPFILES): Likewise. * config/tilegx/linux.mh (NATDEPFILES): Likewise. * config/xtensa/linux.mh (NATDEPFILES): Likewise. * defs.h: Remove #include <stdint.h> (moved to common/common-defs.h). * linux-nat.c: Include nat/linux-personality.h. Remove #include <sys/personality.h>; do not define ADDR_NO_RANDOMIZE (moved to nat/linux-personality.c). (linux_nat_create_inferior): Remove code to disable address space randomization (moved to nat/linux-personality.c). Create cleanup to disable address space randomization. * nat/linux-personality.c: New file. * nat/linux-personality.h: Likewise. gdb/gdbserver/ChangeLog 2015-01-15 Sergio Durigan Junior <sergiodj@redhat.com> * Makefile.in (SFILES): Add linux-personality.c. (linux-personality.o): New rule. * configure.srv (srv_linux_obj): Add linux-personality.o to the list of objects to be built. * linux-low.c: Include nat/linux-personality.h. (linux_create_inferior): Remove code to disable address space randomization (moved to ../nat/linux-personality.c). Create cleanup to disable address space randomization.
2015-01-15 21:10:49 +01:00
#include "nat/linux-personality.h"
#include <signal.h>
#include <sys/ioctl.h>
#include <fcntl.h>
2002-02-14 Daniel Jacobowitz <drow@mvista.com> * gdbserver/Makefile.in: Add regformats directory to INCLUDE_CFLAGS, and remove unused $(INCLUDE_DIR). Add regcache.c to OBS. Add generated register protocol files to clean target. Update dependencies for new objects, obsolete old target code. * gdbserver/linux-low.c: Remove all platform-specific code to new files. Remove various dead code. Update to use regcache functionality. * gdbserver/remote-utils.c (fromhex): Add return statement to quiet warning. (putpkt): Dynamically allocate buf2 because PBUFSIZ is no longer constant. (input_interrupt): Add integer parameter to match prototype of a signal handler. (outreg): Use register_data (). (prepare_resume_reply): Use gdbserver_expedite_regs. * gdbserver/server.c (main): Dynamically allocate own_buf because PBUFSIZ is no longer constant. Use registers_to_string () and registers_from_string (). * gdbserver/server.h: No longer include "defs.h". Add prototypes for error (), fatal (), and warning (). Update definition of PBUFSIZ to use regcache functionality. Add include guard. * gdbserver/utils.c (fatal): Add missing ``const''. (warning): New function. * regformats/regdat.sh: Include "regcache.h" in generated files. Provide init_registers () function. * regformats/regdef.h: Add prototype for set_register_cache (). Add include guard. * gdbserver/linux-arm-low.c: New file. * gdbserver/linux-i386-low.c: New file. * gdbserver/linux-ia64-low.c: New file. * gdbserver/linux-m68k-low.c: New file. * gdbserver/linux-mips-low.c: New file. * gdbserver/linux-ppc-low.c: New file. * gdbserver/linux-sh-low.c: New file. * gdbserver/regcache.c: New file. * gdbserver/regcache.h: New file. * gdbserver/low-linux.c: Removed obsolete file.
2002-02-14 07:21:24 +01:00
#include <unistd.h>
#include <sys/syscall.h>
2007-11-05 20:22:08 +01:00
#include <sched.h>
#include <ctype.h>
#include <pwd.h>
#include <sys/types.h>
#include <dirent.h>
remove gdb_stat.h This patch is purely mechanical. It removes gdb_stat.h and changes the code to use sys/stat.h. 2013-11-18 Tom Tromey <tromey@redhat.com> * common/gdb_stat.h: Remove. * ada-lang.c: Use sys/stat.h, not gdb_stat.h. * common/filestuff.c: Use sys/stat.h, not gdb_stat.h. * common/linux-osdata.c: Use sys/stat.h, not gdb_stat.h. * corefile.c: Use sys/stat.h, not gdb_stat.h. * ctf.c: Use sys/stat.h, not gdb_stat.h. * darwin-nat.c: Use sys/stat.h, not gdb_stat.h. * dbxread.c: Use sys/stat.h, not gdb_stat.h. * dwarf2read.c: Use sys/stat.h, not gdb_stat.h. * exec.c: Use sys/stat.h, not gdb_stat.h. * gdbserver/linux-low.c: Use sys/stat.h, not gdb_stat.h. * gdbserver/remote-utils.c: Use sys/stat.h, not gdb_stat.h. * inf-child.c: Use sys/stat.h, not gdb_stat.h. * jit.c: Use sys/stat.h, not gdb_stat.h. * linux-nat.c: Use sys/stat.h, not gdb_stat.h. * m68klinux-nat.c: Use sys/stat.h, not gdb_stat.h. * main.c: Use sys/stat.h, not gdb_stat.h. * mdebugread.c: Use sys/stat.h, not gdb_stat.h. * mi/mi-cmd-env.c: Use sys/stat.h, not gdb_stat.h. * nto-tdep.c: Use sys/stat.h, not gdb_stat.h. * objfiles.c: Use sys/stat.h, not gdb_stat.h. * procfs.c: Use sys/stat.h, not gdb_stat.h. * remote-fileio.c: Use sys/stat.h, not gdb_stat.h. * remote-mips.c: Use sys/stat.h, not gdb_stat.h. * remote.c: Use sys/stat.h, not gdb_stat.h. * rs6000-nat.c: Use sys/stat.h, not gdb_stat.h. * sol-thread.c: Use sys/stat.h, not gdb_stat.h. * solib-spu.c: Use sys/stat.h, not gdb_stat.h. * source.c: Use sys/stat.h, not gdb_stat.h. * symfile.c: Use sys/stat.h, not gdb_stat.h. * symmisc.c: Use sys/stat.h, not gdb_stat.h. * symtab.c: Use sys/stat.h, not gdb_stat.h. * top.c: Use sys/stat.h, not gdb_stat.h. * xcoffread.c: Use sys/stat.h, not gdb_stat.h.
2013-11-06 15:55:51 +01:00
#include <sys/stat.h>
#include <sys/vfs.h>
Add x86 AVX support to gdbserver. 2010-04-07 H.J. Lu <hongjiu.lu@intel.com> * Makefile.in (clean): Updated. (i386-avx.o): New. (i386-avx.c): Likewise. (i386-avx-linux.o): Likewise. (i386-avx-linux.c): Likewise. (amd64-avx.o): Likewise. (amd64-avx.c): Likewise. (amd64-avx-linux.o): Likewise. (amd64-avx-linux.c): Likewise. * configure.srv (srv_i386_regobj): Add i386-avx.o. (srv_i386_linux_regobj): Add i386-avx-linux.o. (srv_amd64_regobj): Add amd64-avx.o. (srv_amd64_linux_regobj): Add amd64-avx-linux.o. (srv_i386_32bit_xmlfiles): Add i386/32bit-avx.xml. (srv_i386_64bit_xmlfiles): Add i386/64bit-avx.xml. (srv_i386_xmlfiles): Add i386/i386-avx.xml. (srv_amd64_xmlfiles): Add i386/amd64-avx.xml. (srv_i386_linux_xmlfiles): Add i386/i386-avx-linux.xml. (srv_amd64_linux_xmlfiles): Add i386/amd64-avx-linux.xml. * i387-fp.c: Include "i386-xstate.h". (i387_xsave): New. (i387_cache_to_xsave): Likewise. (i387_xsave_to_cache): Likewise. (x86_xcr0): Likewise. * i387-fp.h (i387_cache_to_xsave): Likewise. (i387_xsave_to_cache): Likewise. (x86_xcr0): Likewise. * linux-arm-low.c (target_regsets): Initialize nt_type to 0. * linux-crisv32-low.c (target_regsets): Likewise. * linux-m68k-low.c (target_regsets): Likewise. * linux-mips-low.c (target_regsets): Likewise. * linux-ppc-low.c (target_regsets): Likewise. * linux-s390-low.c (target_regsets): Likewise. * linux-sh-low.c (target_regsets): Likewise. * linux-sparc-low.c (target_regsets): Likewise. * linux-xtensa-low.c (target_regsets): Likewise. * linux-low.c: Include <sys/uio.h>. (regsets_fetch_inferior_registers): Support nt_type. (regsets_store_inferior_registers): Likewise. (linux_process_qsupported): New. (linux_target_ops): Add linux_process_qsupported. * linux-low.h (regset_info): Add nt_type. (linux_target_ops): Add process_qsupported. * linux-x86-low.c: Include "i386-xstate.h", "elf/common.h" and <sys/uio.h>. (init_registers_i386_avx_linux): New. (init_registers_amd64_avx_linux): Likewise. (xmltarget_i386_linux_no_xml): Likewise. (xmltarget_amd64_linux_no_xml): Likewise. (PTRACE_GETREGSET): Likewise. (PTRACE_SETREGSET): Likewise. (x86_fill_xstateregset): Likewise. (x86_store_xstateregset): Likewise. (use_xml): Likewise. (x86_linux_update_xmltarget): Likewise. (x86_linux_process_qsupported): Likewise. (target_regsets): Add NT_X86_XSTATE entry and Initialize nt_type. (x86_arch_setup): Don't call init_registers_amd64_linux nor init_registers_i386_linux here. Call x86_linux_update_xmltarget. (the_low_target): Add x86_linux_process_qsupported. * server.c (handle_query): Call target_process_qsupported. * target.h (target_ops): Add process_qsupported. (target_process_qsupported): New.
2010-04-07 20:49:46 +02:00
#include <sys/uio.h>
Rename common to gdbsupport This is the next patch in the ongoing series to move gdbsever to the top level. This patch just renames the "common" directory. The idea is to do this move in two parts: first rename the directory (this patch), then move the directory to the top. This approach makes the patches a bit more tractable. I chose the name "gdbsupport" for the directory. However, as this patch was largely written by sed, we could pick a new name without too much difficulty. Tested by the buildbot. gdb/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * contrib/ari/gdb_ari.sh: Change common to gdbsupport. * configure: Rebuild. * configure.ac: Change common to gdbsupport. * gdbsupport: Rename from common. * acinclude.m4: Change common to gdbsupport. * Makefile.in (CONFIG_SRC_SUBDIR, COMMON_SFILES) (HFILES_NO_SRCDIR, stamp-version, ALLDEPFILES): Change common to gdbsupport. * aarch64-tdep.c, ada-lang.c, ada-lang.h, agent.c, alloc.c, amd64-darwin-tdep.c, amd64-dicos-tdep.c, amd64-fbsd-nat.c, amd64-fbsd-tdep.c, amd64-linux-nat.c, amd64-linux-tdep.c, amd64-nbsd-tdep.c, amd64-obsd-tdep.c, amd64-sol2-tdep.c, amd64-tdep.c, amd64-windows-tdep.c, arch-utils.c, arch/aarch64-insn.c, arch/aarch64.c, arch/aarch64.h, arch/amd64.c, arch/amd64.h, arch/arm-get-next-pcs.c, arch/arm-linux.c, arch/arm.c, arch/i386.c, arch/i386.h, arch/ppc-linux-common.c, arch/riscv.c, arch/riscv.h, arch/tic6x.c, arm-tdep.c, auto-load.c, auxv.c, ax-gdb.c, ax-general.c, ax.h, breakpoint.c, breakpoint.h, btrace.c, btrace.h, build-id.c, build-id.h, c-lang.h, charset.c, charset.h, cli/cli-cmds.c, cli/cli-cmds.h, cli/cli-decode.c, cli/cli-dump.c, cli/cli-option.h, cli/cli-script.c, coff-pe-read.c, command.h, compile/compile-c-support.c, compile/compile-c.h, compile/compile-cplus-symbols.c, compile/compile-cplus-types.c, compile/compile-cplus.h, compile/compile-loc2c.c, compile/compile.c, completer.c, completer.h, contrib/ari/gdb_ari.sh, corefile.c, corelow.c, cp-support.c, cp-support.h, cp-valprint.c, csky-tdep.c, ctf.c, darwin-nat.c, debug.c, defs.h, disasm-selftests.c, disasm.c, disasm.h, dtrace-probe.c, dwarf-index-cache.c, dwarf-index-cache.h, dwarf-index-write.c, dwarf2-frame.c, dwarf2expr.c, dwarf2loc.c, dwarf2read.c, event-loop.c, event-top.c, exceptions.c, exec.c, extension.h, fbsd-nat.c, features/aarch64-core.c, features/aarch64-fpu.c, features/aarch64-pauth.c, features/aarch64-sve.c, features/i386/32bit-avx.c, features/i386/32bit-avx512.c, features/i386/32bit-core.c, features/i386/32bit-linux.c, features/i386/32bit-mpx.c, features/i386/32bit-pkeys.c, features/i386/32bit-segments.c, features/i386/32bit-sse.c, features/i386/64bit-avx.c, features/i386/64bit-avx512.c, features/i386/64bit-core.c, features/i386/64bit-linux.c, features/i386/64bit-mpx.c, features/i386/64bit-pkeys.c, features/i386/64bit-segments.c, features/i386/64bit-sse.c, features/i386/x32-core.c, features/riscv/32bit-cpu.c, features/riscv/32bit-csr.c, features/riscv/32bit-fpu.c, features/riscv/64bit-cpu.c, features/riscv/64bit-csr.c, features/riscv/64bit-fpu.c, features/tic6x-c6xp.c, features/tic6x-core.c, features/tic6x-gp.c, filename-seen-cache.h, findcmd.c, findvar.c, fork-child.c, gcore.c, gdb_bfd.c, gdb_bfd.h, gdb_proc_service.h, gdb_regex.c, gdb_select.h, gdb_usleep.c, gdbarch-selftests.c, gdbthread.h, gdbtypes.h, gnu-nat.c, go32-nat.c, guile/guile.c, guile/scm-ports.c, guile/scm-safe-call.c, guile/scm-type.c, i386-fbsd-nat.c, i386-fbsd-tdep.c, i386-go32-tdep.c, i386-linux-nat.c, i386-linux-tdep.c, i386-tdep.c, i387-tdep.c, ia64-libunwind-tdep.c, ia64-linux-nat.c, inf-child.c, inf-ptrace.c, infcall.c, infcall.h, infcmd.c, inferior-iter.h, inferior.c, inferior.h, inflow.c, inflow.h, infrun.c, infrun.h, inline-frame.c, language.h, linespec.c, linux-fork.c, linux-nat.c, linux-tdep.c, linux-thread-db.c, location.c, machoread.c, macrotab.h, main.c, maint.c, maint.h, memattr.c, memrange.h, mi/mi-cmd-break.h, mi/mi-cmd-env.c, mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-interp.c, mi/mi-main.c, mi/mi-parse.h, minsyms.c, mips-linux-tdep.c, namespace.h, nat/aarch64-linux-hw-point.c, nat/aarch64-linux-hw-point.h, nat/aarch64-linux.c, nat/aarch64-sve-linux-ptrace.c, nat/amd64-linux-siginfo.c, nat/fork-inferior.c, nat/linux-btrace.c, nat/linux-btrace.h, nat/linux-namespaces.c, nat/linux-nat.h, nat/linux-osdata.c, nat/linux-personality.c, nat/linux-procfs.c, nat/linux-ptrace.c, nat/linux-ptrace.h, nat/linux-waitpid.c, nat/mips-linux-watch.c, nat/mips-linux-watch.h, nat/ppc-linux.c, nat/x86-dregs.c, nat/x86-dregs.h, nat/x86-linux-dregs.c, nat/x86-linux.c, nto-procfs.c, nto-tdep.c, objfile-flags.h, objfiles.c, objfiles.h, obsd-nat.c, observable.h, osdata.c, p-valprint.c, parse.c, parser-defs.h, ppc-linux-nat.c, printcmd.c, probe.c, proc-api.c, procfs.c, producer.c, progspace.h, psymtab.h, python/py-framefilter.c, python/py-inferior.c, python/py-ref.h, python/py-type.c, python/python.c, record-btrace.c, record-full.c, record.c, record.h, regcache-dump.c, regcache.c, regcache.h, remote-fileio.c, remote-fileio.h, remote-sim.c, remote.c, riscv-tdep.c, rs6000-aix-tdep.c, rust-exp.y, s12z-tdep.c, selftest-arch.c, ser-base.c, ser-event.c, ser-pipe.c, ser-tcp.c, ser-unix.c, skip.c, solib-aix.c, solib-target.c, solib.c, source-cache.c, source.c, source.h, sparc-nat.c, spu-linux-nat.c, stack.c, stap-probe.c, symfile-add-flags.h, symfile.c, symfile.h, symtab.c, symtab.h, target-descriptions.c, target-descriptions.h, target-memory.c, target.c, target.h, target/waitstatus.c, target/waitstatus.h, thread-iter.h, thread.c, tilegx-tdep.c, top.c, top.h, tracefile-tfile.c, tracefile.c, tracepoint.c, tracepoint.h, tui/tui-io.c, ui-file.c, ui-out.h, unittests/array-view-selftests.c, unittests/child-path-selftests.c, unittests/cli-utils-selftests.c, unittests/common-utils-selftests.c, unittests/copy_bitwise-selftests.c, unittests/environ-selftests.c, unittests/format_pieces-selftests.c, unittests/function-view-selftests.c, unittests/lookup_name_info-selftests.c, unittests/memory-map-selftests.c, unittests/memrange-selftests.c, unittests/mkdir-recursive-selftests.c, unittests/observable-selftests.c, unittests/offset-type-selftests.c, unittests/optional-selftests.c, unittests/parse-connection-spec-selftests.c, unittests/ptid-selftests.c, unittests/rsp-low-selftests.c, unittests/scoped_fd-selftests.c, unittests/scoped_mmap-selftests.c, unittests/scoped_restore-selftests.c, unittests/string_view-selftests.c, unittests/style-selftests.c, unittests/tracepoint-selftests.c, unittests/unpack-selftests.c, unittests/utils-selftests.c, unittests/xml-utils-selftests.c, utils.c, utils.h, valarith.c, valops.c, valprint.c, value.c, value.h, varobj.c, varobj.h, windows-nat.c, x86-linux-nat.c, xml-support.c, xml-support.h, xml-tdesc.h, xstormy16-tdep.c, xtensa-linux-nat.c, dwarf2read.h: Change common to gdbsupport. gdb/gdbserver/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * configure: Rebuild. * configure.ac: Change common to gdbsupport. * acinclude.m4: Change common to gdbsupport. * Makefile.in (SFILES, OBS, GDBREPLAY_OBS, IPA_OBJS) (version-generated.c, gdbsupport/%-ipa.o, gdbsupport/%.o): Change common to gdbsupport. * ax.c, event-loop.c, fork-child.c, gdb_proc_service.h, gdbreplay.c, gdbthread.h, hostio-errno.c, hostio.c, i387-fp.c, inferiors.c, inferiors.h, linux-aarch64-tdesc-selftest.c, linux-amd64-ipa.c, linux-i386-ipa.c, linux-low.c, linux-tic6x-low.c, linux-x86-low.c, linux-x86-tdesc-selftest.c, linux-x86-tdesc.c, lynx-i386-low.c, lynx-low.c, mem-break.h, nto-x86-low.c, regcache.c, regcache.h, remote-utils.c, server.c, server.h, spu-low.c, symbol.c, target.h, tdesc.c, tdesc.h, thread-db.c, tracepoint.c, win32-i386-low.c, win32-low.c: Change common to gdbsupport.
2019-05-06 04:29:24 +02:00
#include "gdbsupport/filestuff.h"
#include "tracepoint.h"
Replace some $ARCH_{get,set}_pc with linux_{get,set}_pc_32bit This patch adds a pair of new functions linux_get_pc_32bit and linux_set_pc_32bit which get and set 32-bit register "pc" from regcache. This function can be used some targets and these own $ARCH_{get,set}_pc are replaced by linux_{get,set}_pc_32bit respectively. This patch touches many targets, but I only have arm board to test and no regression. I also rebuilt nios2-linux GDBserver. If it is right to go, I'll post the 64-bit counterpart later. gdb/gdbserver: 2016-01-18 Yao Qi <yao.qi@linaro.org> * linux-arm-low.c (debug_threads): Remove declaration. (arm_get_pc, arm_set_pc): Remove. (the_low_target): Use linux_get_pc_32bit and linux_set_pc_32bit. * linux-bfin-low.c (bfin_get_pc, bfin_set_pc): Remove. (the_low_target): Use linux_get_pc_32bit and linux_set_pc_32bit. * linux-cris-low.c (debug_threads): Remove declaration. (cris_get_pc, cris_set_pc,): Remove. (the_low_target): Use linux_get_pc_32bit and linux_set_pc_32bit. * linux-crisv32-low.c (debug_threads): Remove declaration. (cris_get_pc, cris_set_pc): Remove. (the_low_target): Use linux_get_pc_32bit and linux_set_pc_32bit. * linux-low.c: Include inttypes.h. (linux_get_pc_32bit, linux_set_pc_32bit): New functions. * linux-low.h (linux_get_pc_32bit, linux_set_pc_32bit): Declare. * linux-m32r-low.c (m32r_get_pc, m32r_set_pc): Remove. (the_low_target): Use linux_get_pc_32bit and linux_set_pc_32bit. * linux-m68k-low.c (m68k_get_pc, m68k_set_pc): Remove. (the_low_target): Use linux_get_pc_32bit and linux_set_pc_32bit. * linux-nios2-low.c (nios2_get_pc, nios2_set_pc): Remove. (the_low_target): Use linux_get_pc_32bit and linux_set_pc_32bit. * linux-sh-low.c (sh_get_pc, sh_set_pc): Remove. (the_low_target): Use linux_get_pc_32bit and linux_set_pc_32bit. * linux-xtensa-low.c (xtensa_get_pc, xtensa_set_pc): Remove. (the_low_target): Use linux_get_pc_32bit and linux_set_pc_32bit.
2016-01-18 15:49:50 +01:00
#include <inttypes.h>
Rename common to gdbsupport This is the next patch in the ongoing series to move gdbsever to the top level. This patch just renames the "common" directory. The idea is to do this move in two parts: first rename the directory (this patch), then move the directory to the top. This approach makes the patches a bit more tractable. I chose the name "gdbsupport" for the directory. However, as this patch was largely written by sed, we could pick a new name without too much difficulty. Tested by the buildbot. gdb/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * contrib/ari/gdb_ari.sh: Change common to gdbsupport. * configure: Rebuild. * configure.ac: Change common to gdbsupport. * gdbsupport: Rename from common. * acinclude.m4: Change common to gdbsupport. * Makefile.in (CONFIG_SRC_SUBDIR, COMMON_SFILES) (HFILES_NO_SRCDIR, stamp-version, ALLDEPFILES): Change common to gdbsupport. * aarch64-tdep.c, ada-lang.c, ada-lang.h, agent.c, alloc.c, amd64-darwin-tdep.c, amd64-dicos-tdep.c, amd64-fbsd-nat.c, amd64-fbsd-tdep.c, amd64-linux-nat.c, amd64-linux-tdep.c, amd64-nbsd-tdep.c, amd64-obsd-tdep.c, amd64-sol2-tdep.c, amd64-tdep.c, amd64-windows-tdep.c, arch-utils.c, arch/aarch64-insn.c, arch/aarch64.c, arch/aarch64.h, arch/amd64.c, arch/amd64.h, arch/arm-get-next-pcs.c, arch/arm-linux.c, arch/arm.c, arch/i386.c, arch/i386.h, arch/ppc-linux-common.c, arch/riscv.c, arch/riscv.h, arch/tic6x.c, arm-tdep.c, auto-load.c, auxv.c, ax-gdb.c, ax-general.c, ax.h, breakpoint.c, breakpoint.h, btrace.c, btrace.h, build-id.c, build-id.h, c-lang.h, charset.c, charset.h, cli/cli-cmds.c, cli/cli-cmds.h, cli/cli-decode.c, cli/cli-dump.c, cli/cli-option.h, cli/cli-script.c, coff-pe-read.c, command.h, compile/compile-c-support.c, compile/compile-c.h, compile/compile-cplus-symbols.c, compile/compile-cplus-types.c, compile/compile-cplus.h, compile/compile-loc2c.c, compile/compile.c, completer.c, completer.h, contrib/ari/gdb_ari.sh, corefile.c, corelow.c, cp-support.c, cp-support.h, cp-valprint.c, csky-tdep.c, ctf.c, darwin-nat.c, debug.c, defs.h, disasm-selftests.c, disasm.c, disasm.h, dtrace-probe.c, dwarf-index-cache.c, dwarf-index-cache.h, dwarf-index-write.c, dwarf2-frame.c, dwarf2expr.c, dwarf2loc.c, dwarf2read.c, event-loop.c, event-top.c, exceptions.c, exec.c, extension.h, fbsd-nat.c, features/aarch64-core.c, features/aarch64-fpu.c, features/aarch64-pauth.c, features/aarch64-sve.c, features/i386/32bit-avx.c, features/i386/32bit-avx512.c, features/i386/32bit-core.c, features/i386/32bit-linux.c, features/i386/32bit-mpx.c, features/i386/32bit-pkeys.c, features/i386/32bit-segments.c, features/i386/32bit-sse.c, features/i386/64bit-avx.c, features/i386/64bit-avx512.c, features/i386/64bit-core.c, features/i386/64bit-linux.c, features/i386/64bit-mpx.c, features/i386/64bit-pkeys.c, features/i386/64bit-segments.c, features/i386/64bit-sse.c, features/i386/x32-core.c, features/riscv/32bit-cpu.c, features/riscv/32bit-csr.c, features/riscv/32bit-fpu.c, features/riscv/64bit-cpu.c, features/riscv/64bit-csr.c, features/riscv/64bit-fpu.c, features/tic6x-c6xp.c, features/tic6x-core.c, features/tic6x-gp.c, filename-seen-cache.h, findcmd.c, findvar.c, fork-child.c, gcore.c, gdb_bfd.c, gdb_bfd.h, gdb_proc_service.h, gdb_regex.c, gdb_select.h, gdb_usleep.c, gdbarch-selftests.c, gdbthread.h, gdbtypes.h, gnu-nat.c, go32-nat.c, guile/guile.c, guile/scm-ports.c, guile/scm-safe-call.c, guile/scm-type.c, i386-fbsd-nat.c, i386-fbsd-tdep.c, i386-go32-tdep.c, i386-linux-nat.c, i386-linux-tdep.c, i386-tdep.c, i387-tdep.c, ia64-libunwind-tdep.c, ia64-linux-nat.c, inf-child.c, inf-ptrace.c, infcall.c, infcall.h, infcmd.c, inferior-iter.h, inferior.c, inferior.h, inflow.c, inflow.h, infrun.c, infrun.h, inline-frame.c, language.h, linespec.c, linux-fork.c, linux-nat.c, linux-tdep.c, linux-thread-db.c, location.c, machoread.c, macrotab.h, main.c, maint.c, maint.h, memattr.c, memrange.h, mi/mi-cmd-break.h, mi/mi-cmd-env.c, mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-interp.c, mi/mi-main.c, mi/mi-parse.h, minsyms.c, mips-linux-tdep.c, namespace.h, nat/aarch64-linux-hw-point.c, nat/aarch64-linux-hw-point.h, nat/aarch64-linux.c, nat/aarch64-sve-linux-ptrace.c, nat/amd64-linux-siginfo.c, nat/fork-inferior.c, nat/linux-btrace.c, nat/linux-btrace.h, nat/linux-namespaces.c, nat/linux-nat.h, nat/linux-osdata.c, nat/linux-personality.c, nat/linux-procfs.c, nat/linux-ptrace.c, nat/linux-ptrace.h, nat/linux-waitpid.c, nat/mips-linux-watch.c, nat/mips-linux-watch.h, nat/ppc-linux.c, nat/x86-dregs.c, nat/x86-dregs.h, nat/x86-linux-dregs.c, nat/x86-linux.c, nto-procfs.c, nto-tdep.c, objfile-flags.h, objfiles.c, objfiles.h, obsd-nat.c, observable.h, osdata.c, p-valprint.c, parse.c, parser-defs.h, ppc-linux-nat.c, printcmd.c, probe.c, proc-api.c, procfs.c, producer.c, progspace.h, psymtab.h, python/py-framefilter.c, python/py-inferior.c, python/py-ref.h, python/py-type.c, python/python.c, record-btrace.c, record-full.c, record.c, record.h, regcache-dump.c, regcache.c, regcache.h, remote-fileio.c, remote-fileio.h, remote-sim.c, remote.c, riscv-tdep.c, rs6000-aix-tdep.c, rust-exp.y, s12z-tdep.c, selftest-arch.c, ser-base.c, ser-event.c, ser-pipe.c, ser-tcp.c, ser-unix.c, skip.c, solib-aix.c, solib-target.c, solib.c, source-cache.c, source.c, source.h, sparc-nat.c, spu-linux-nat.c, stack.c, stap-probe.c, symfile-add-flags.h, symfile.c, symfile.h, symtab.c, symtab.h, target-descriptions.c, target-descriptions.h, target-memory.c, target.c, target.h, target/waitstatus.c, target/waitstatus.h, thread-iter.h, thread.c, tilegx-tdep.c, top.c, top.h, tracefile-tfile.c, tracefile.c, tracepoint.c, tracepoint.h, tui/tui-io.c, ui-file.c, ui-out.h, unittests/array-view-selftests.c, unittests/child-path-selftests.c, unittests/cli-utils-selftests.c, unittests/common-utils-selftests.c, unittests/copy_bitwise-selftests.c, unittests/environ-selftests.c, unittests/format_pieces-selftests.c, unittests/function-view-selftests.c, unittests/lookup_name_info-selftests.c, unittests/memory-map-selftests.c, unittests/memrange-selftests.c, unittests/mkdir-recursive-selftests.c, unittests/observable-selftests.c, unittests/offset-type-selftests.c, unittests/optional-selftests.c, unittests/parse-connection-spec-selftests.c, unittests/ptid-selftests.c, unittests/rsp-low-selftests.c, unittests/scoped_fd-selftests.c, unittests/scoped_mmap-selftests.c, unittests/scoped_restore-selftests.c, unittests/string_view-selftests.c, unittests/style-selftests.c, unittests/tracepoint-selftests.c, unittests/unpack-selftests.c, unittests/utils-selftests.c, unittests/xml-utils-selftests.c, utils.c, utils.h, valarith.c, valops.c, valprint.c, value.c, value.h, varobj.c, varobj.h, windows-nat.c, x86-linux-nat.c, xml-support.c, xml-support.h, xml-tdesc.h, xstormy16-tdep.c, xtensa-linux-nat.c, dwarf2read.h: Change common to gdbsupport. gdb/gdbserver/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * configure: Rebuild. * configure.ac: Change common to gdbsupport. * acinclude.m4: Change common to gdbsupport. * Makefile.in (SFILES, OBS, GDBREPLAY_OBS, IPA_OBJS) (version-generated.c, gdbsupport/%-ipa.o, gdbsupport/%.o): Change common to gdbsupport. * ax.c, event-loop.c, fork-child.c, gdb_proc_service.h, gdbreplay.c, gdbthread.h, hostio-errno.c, hostio.c, i387-fp.c, inferiors.c, inferiors.h, linux-aarch64-tdesc-selftest.c, linux-amd64-ipa.c, linux-i386-ipa.c, linux-low.c, linux-tic6x-low.c, linux-x86-low.c, linux-x86-tdesc-selftest.c, linux-x86-tdesc.c, lynx-i386-low.c, lynx-low.c, mem-break.h, nto-x86-low.c, regcache.c, regcache.h, remote-utils.c, server.c, server.h, spu-low.c, symbol.c, target.h, tdesc.c, tdesc.h, thread-db.c, tracepoint.c, win32-i386-low.c, win32-low.c: Change common to gdbsupport.
2019-05-06 04:29:24 +02:00
#include "gdbsupport/common-inferior.h"
Share fork_inferior et al with gdbserver This is the most important (and the biggest, sorry) patch of the series. It moves fork_inferior from gdb/fork-child.c to nat/fork-inferior.c and makes all the necessary adjustments to both GDB and gdbserver to make sure everything works OK. There is no "most important change" with this patch; all changes are made in a progressive way, making sure that gdbserver had the necessary features while not breaking GDB at the same time. I decided to go ahead and implement a partial support for starting the inferior with a shell on gdbserver, although the full feature comes in the next patch. The user won't have the option to disable the startup-with-shell, and also won't be able to change which shell gdbserver will use (other than setting the $SHELL environment variable, that is). Everything is working as expected, and no regressions were present during the tests. gdb/ChangeLog: 2017-06-07 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> * Makefile.in (HFILES_NO_SRCDIR): Add "common/common-inferior.h" and "nat/fork-inferior.h". * common/common-inferior.h: New file, with contents from "gdb/inferior.h". * commom/common-utils.c: Include "common-utils.h". (stringify_argv): New function. * common/common-utils.h (stringify_argv): New prototype. * configure.nat: Add "fork-inferior.o" as a dependency for "*linux*", "fbsd*" and "nbsd*" hosts. * corefile.c (get_exec_file): Update comment. * darwin-nat.c (darwin_ptrace_him): Call "gdb_startup_inferior" instead of "startup_inferior". (darwin_create_inferior): Call "add_thread_silent" after "fork_inferior". * fork-child.c: Cleanup unnecessary includes. (SHELL_FILE): Move to "common/common-fork-child.c". (environ): Likewise. (exec_wrapper): Initialize. (get_exec_wrapper): New function. (breakup_args): Move to "common/common-fork-child.c"; rename to "breakup_args_for_exec". (escape_bang_in_quoted_argument): Move to "common/common-fork-child.c". (saved_ui): New variable. (prefork_hook): New function. (postfork_hook): Likewise. (postfork_child_hook): Likewise. (gdb_startup_inferior): Likewise. (fork_inferior): Move to "common/common-fork-child.c". Update function to support gdbserver. (startup_inferior): Likewise. * gdbcore.h (get_exec_file): Remove declaration. * gnu-nat.c (gnu_create_inferior): Call "gdb_startup_inferior" instead of "startup_inferior". Call "add_thread_silent" after "fork_inferior". * inf-ptrace.c: Include "nat/fork-inferior.h" and "utils.h". (inf_ptrace_create_inferior): Call "gdb_startup_inferior" instead of "startup_inferior". Call "add_thread_silent" after "fork_inferior". * inferior.h: Include "common-inferior.h". (trace_start_error): Move to "common/common-utils.h". (trace_start_error_with_name): Likewise. (fork_inferior): Move prototype to "nat/fork-inferior.h". (startup_inferior): Likewise. (gdb_startup_inferior): New prototype. * nat/fork-inferior.c: New file, with contents from "fork-child.c". * nat/fork-inferior.h: New file. * procfs.c (procfs_init_inferior): Call "gdb_startup_inferior" instead of "startup_inferior". Call "add_thread_silent" after "fork_inferior". * target.h (target_terminal_init): Move prototype to "target/target.h". (target_terminal_inferior): Likewise. (target_terminal_ours): Likewise. * target/target.h (target_terminal_init): New prototype, moved from "target.h". (target_terminal_inferior): Likewise. (target_terminal_ours): Likewise. * utils.c (gdb_flush_out_err): New function. gdb/gdbserver/ChangeLog: 2017-06-07 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> * Makefile.in (SFILES): Add "nat/fork-inferior.o". * configure: Regenerate. * configure.srv (srv_linux_obj): Add "fork-child.o" and "fork-inferior.o". (i[34567]86-*-lynxos*): Likewise. (spu*-*-*): Likewise. * fork-child.c: New file. * linux-low.c: Include "common-inferior.h", "nat/fork-inferior.h" and "environ.h". (linux_ptrace_fun): New function. (linux_create_inferior): Adjust function prototype to reflect change on "target.h". Adjust function code to use "fork_inferior". (linux_request_interrupt): Delete "signal_pid". * lynx-low.c: Include "common-inferior.h" and "nat/fork-inferior.h". (lynx_ptrace_fun): New function. (lynx_create_inferior): Adjust function prototype to reflect change on "target.h". Adjust function code to use "fork_inferior". * nto-low.c (nto_create_inferior): Adjust function prototype and code to reflect change on "target.h". Update comments. * server.c: Include "common-inferior.h", "nat/fork-inferior.h", "common-terminal.h" and "environ.h". (terminal_fd): Moved to fork-child.c. (old_foreground_pgrp): Likewise. (restore_old_foreground_pgrp): Likewise. (last_status): Make it global. (last_ptid): Likewise. (our_environ): New variable. (startup_with_shell): Likewise. (program_name): Likewise. (program_argv): Rename to... (program_args): ...this. (wrapper_argv): New variable. (start_inferior): Delete function. (get_exec_wrapper): New function. (get_exec_file): Likewise. (get_environ): Likewise. (prefork_hook): Likewise. (post_fork_inferior): Likewise. (postfork_hook): Likewise. (postfork_child_hook): Likewise. (handle_v_run): Update code to deal with arguments coming from the remote host. Update calls from "start_inferior" to "create_inferior". (captured_main): Likewise. Initialize environment variable. Call "have_job_control". * server.h (post_fork_inferior): New prototype. (get_environ): Likewise. (last_status): Declare. (last_ptid): Likewise. (signal_pid): Likewise. * spu-low.c: Include "common-inferior.h" and "nat/fork-inferior.h". (spu_ptrace_fun): New function. (spu_create_inferior): Adjust function prototype to reflect change on "target.h". Adjust function code to use "fork_inferior". * target.c (target_terminal_init): New function. (target_terminal_inferior): Likewise. (target_terminal_ours): Likewise. * target.h: Include <vector>. (struct target_ops) <create_inferior>: Update prototype. (create_inferior): Update macro. * utils.c (gdb_flush_out_err): New function. * win32-low.c (win32_create_inferior): Adjust function prototype and code to reflect change on "target.h". gdb/testsuite/ChangeLog: 2017-06-07 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.server/non-existing-program.exp: Update regex in order to reflect the fact that gdbserver is now using fork_inferior (with a shell) to startup the inferior.
2016-12-23 03:11:11 +01:00
#include "nat/fork-inferior.h"
Rename common to gdbsupport This is the next patch in the ongoing series to move gdbsever to the top level. This patch just renames the "common" directory. The idea is to do this move in two parts: first rename the directory (this patch), then move the directory to the top. This approach makes the patches a bit more tractable. I chose the name "gdbsupport" for the directory. However, as this patch was largely written by sed, we could pick a new name without too much difficulty. Tested by the buildbot. gdb/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * contrib/ari/gdb_ari.sh: Change common to gdbsupport. * configure: Rebuild. * configure.ac: Change common to gdbsupport. * gdbsupport: Rename from common. * acinclude.m4: Change common to gdbsupport. * Makefile.in (CONFIG_SRC_SUBDIR, COMMON_SFILES) (HFILES_NO_SRCDIR, stamp-version, ALLDEPFILES): Change common to gdbsupport. * aarch64-tdep.c, ada-lang.c, ada-lang.h, agent.c, alloc.c, amd64-darwin-tdep.c, amd64-dicos-tdep.c, amd64-fbsd-nat.c, amd64-fbsd-tdep.c, amd64-linux-nat.c, amd64-linux-tdep.c, amd64-nbsd-tdep.c, amd64-obsd-tdep.c, amd64-sol2-tdep.c, amd64-tdep.c, amd64-windows-tdep.c, arch-utils.c, arch/aarch64-insn.c, arch/aarch64.c, arch/aarch64.h, arch/amd64.c, arch/amd64.h, arch/arm-get-next-pcs.c, arch/arm-linux.c, arch/arm.c, arch/i386.c, arch/i386.h, arch/ppc-linux-common.c, arch/riscv.c, arch/riscv.h, arch/tic6x.c, arm-tdep.c, auto-load.c, auxv.c, ax-gdb.c, ax-general.c, ax.h, breakpoint.c, breakpoint.h, btrace.c, btrace.h, build-id.c, build-id.h, c-lang.h, charset.c, charset.h, cli/cli-cmds.c, cli/cli-cmds.h, cli/cli-decode.c, cli/cli-dump.c, cli/cli-option.h, cli/cli-script.c, coff-pe-read.c, command.h, compile/compile-c-support.c, compile/compile-c.h, compile/compile-cplus-symbols.c, compile/compile-cplus-types.c, compile/compile-cplus.h, compile/compile-loc2c.c, compile/compile.c, completer.c, completer.h, contrib/ari/gdb_ari.sh, corefile.c, corelow.c, cp-support.c, cp-support.h, cp-valprint.c, csky-tdep.c, ctf.c, darwin-nat.c, debug.c, defs.h, disasm-selftests.c, disasm.c, disasm.h, dtrace-probe.c, dwarf-index-cache.c, dwarf-index-cache.h, dwarf-index-write.c, dwarf2-frame.c, dwarf2expr.c, dwarf2loc.c, dwarf2read.c, event-loop.c, event-top.c, exceptions.c, exec.c, extension.h, fbsd-nat.c, features/aarch64-core.c, features/aarch64-fpu.c, features/aarch64-pauth.c, features/aarch64-sve.c, features/i386/32bit-avx.c, features/i386/32bit-avx512.c, features/i386/32bit-core.c, features/i386/32bit-linux.c, features/i386/32bit-mpx.c, features/i386/32bit-pkeys.c, features/i386/32bit-segments.c, features/i386/32bit-sse.c, features/i386/64bit-avx.c, features/i386/64bit-avx512.c, features/i386/64bit-core.c, features/i386/64bit-linux.c, features/i386/64bit-mpx.c, features/i386/64bit-pkeys.c, features/i386/64bit-segments.c, features/i386/64bit-sse.c, features/i386/x32-core.c, features/riscv/32bit-cpu.c, features/riscv/32bit-csr.c, features/riscv/32bit-fpu.c, features/riscv/64bit-cpu.c, features/riscv/64bit-csr.c, features/riscv/64bit-fpu.c, features/tic6x-c6xp.c, features/tic6x-core.c, features/tic6x-gp.c, filename-seen-cache.h, findcmd.c, findvar.c, fork-child.c, gcore.c, gdb_bfd.c, gdb_bfd.h, gdb_proc_service.h, gdb_regex.c, gdb_select.h, gdb_usleep.c, gdbarch-selftests.c, gdbthread.h, gdbtypes.h, gnu-nat.c, go32-nat.c, guile/guile.c, guile/scm-ports.c, guile/scm-safe-call.c, guile/scm-type.c, i386-fbsd-nat.c, i386-fbsd-tdep.c, i386-go32-tdep.c, i386-linux-nat.c, i386-linux-tdep.c, i386-tdep.c, i387-tdep.c, ia64-libunwind-tdep.c, ia64-linux-nat.c, inf-child.c, inf-ptrace.c, infcall.c, infcall.h, infcmd.c, inferior-iter.h, inferior.c, inferior.h, inflow.c, inflow.h, infrun.c, infrun.h, inline-frame.c, language.h, linespec.c, linux-fork.c, linux-nat.c, linux-tdep.c, linux-thread-db.c, location.c, machoread.c, macrotab.h, main.c, maint.c, maint.h, memattr.c, memrange.h, mi/mi-cmd-break.h, mi/mi-cmd-env.c, mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-interp.c, mi/mi-main.c, mi/mi-parse.h, minsyms.c, mips-linux-tdep.c, namespace.h, nat/aarch64-linux-hw-point.c, nat/aarch64-linux-hw-point.h, nat/aarch64-linux.c, nat/aarch64-sve-linux-ptrace.c, nat/amd64-linux-siginfo.c, nat/fork-inferior.c, nat/linux-btrace.c, nat/linux-btrace.h, nat/linux-namespaces.c, nat/linux-nat.h, nat/linux-osdata.c, nat/linux-personality.c, nat/linux-procfs.c, nat/linux-ptrace.c, nat/linux-ptrace.h, nat/linux-waitpid.c, nat/mips-linux-watch.c, nat/mips-linux-watch.h, nat/ppc-linux.c, nat/x86-dregs.c, nat/x86-dregs.h, nat/x86-linux-dregs.c, nat/x86-linux.c, nto-procfs.c, nto-tdep.c, objfile-flags.h, objfiles.c, objfiles.h, obsd-nat.c, observable.h, osdata.c, p-valprint.c, parse.c, parser-defs.h, ppc-linux-nat.c, printcmd.c, probe.c, proc-api.c, procfs.c, producer.c, progspace.h, psymtab.h, python/py-framefilter.c, python/py-inferior.c, python/py-ref.h, python/py-type.c, python/python.c, record-btrace.c, record-full.c, record.c, record.h, regcache-dump.c, regcache.c, regcache.h, remote-fileio.c, remote-fileio.h, remote-sim.c, remote.c, riscv-tdep.c, rs6000-aix-tdep.c, rust-exp.y, s12z-tdep.c, selftest-arch.c, ser-base.c, ser-event.c, ser-pipe.c, ser-tcp.c, ser-unix.c, skip.c, solib-aix.c, solib-target.c, solib.c, source-cache.c, source.c, source.h, sparc-nat.c, spu-linux-nat.c, stack.c, stap-probe.c, symfile-add-flags.h, symfile.c, symfile.h, symtab.c, symtab.h, target-descriptions.c, target-descriptions.h, target-memory.c, target.c, target.h, target/waitstatus.c, target/waitstatus.h, thread-iter.h, thread.c, tilegx-tdep.c, top.c, top.h, tracefile-tfile.c, tracefile.c, tracepoint.c, tracepoint.h, tui/tui-io.c, ui-file.c, ui-out.h, unittests/array-view-selftests.c, unittests/child-path-selftests.c, unittests/cli-utils-selftests.c, unittests/common-utils-selftests.c, unittests/copy_bitwise-selftests.c, unittests/environ-selftests.c, unittests/format_pieces-selftests.c, unittests/function-view-selftests.c, unittests/lookup_name_info-selftests.c, unittests/memory-map-selftests.c, unittests/memrange-selftests.c, unittests/mkdir-recursive-selftests.c, unittests/observable-selftests.c, unittests/offset-type-selftests.c, unittests/optional-selftests.c, unittests/parse-connection-spec-selftests.c, unittests/ptid-selftests.c, unittests/rsp-low-selftests.c, unittests/scoped_fd-selftests.c, unittests/scoped_mmap-selftests.c, unittests/scoped_restore-selftests.c, unittests/string_view-selftests.c, unittests/style-selftests.c, unittests/tracepoint-selftests.c, unittests/unpack-selftests.c, unittests/utils-selftests.c, unittests/xml-utils-selftests.c, utils.c, utils.h, valarith.c, valops.c, valprint.c, value.c, value.h, varobj.c, varobj.h, windows-nat.c, x86-linux-nat.c, xml-support.c, xml-support.h, xml-tdesc.h, xstormy16-tdep.c, xtensa-linux-nat.c, dwarf2read.h: Change common to gdbsupport. gdb/gdbserver/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * configure: Rebuild. * configure.ac: Change common to gdbsupport. * acinclude.m4: Change common to gdbsupport. * Makefile.in (SFILES, OBS, GDBREPLAY_OBS, IPA_OBJS) (version-generated.c, gdbsupport/%-ipa.o, gdbsupport/%.o): Change common to gdbsupport. * ax.c, event-loop.c, fork-child.c, gdb_proc_service.h, gdbreplay.c, gdbthread.h, hostio-errno.c, hostio.c, i387-fp.c, inferiors.c, inferiors.h, linux-aarch64-tdesc-selftest.c, linux-amd64-ipa.c, linux-i386-ipa.c, linux-low.c, linux-tic6x-low.c, linux-x86-low.c, linux-x86-tdesc-selftest.c, linux-x86-tdesc.c, lynx-i386-low.c, lynx-low.c, mem-break.h, nto-x86-low.c, regcache.c, regcache.h, remote-utils.c, server.c, server.h, spu-low.c, symbol.c, target.h, tdesc.c, tdesc.h, thread-db.c, tracepoint.c, win32-i386-low.c, win32-low.c: Change common to gdbsupport.
2019-05-06 04:29:24 +02:00
#include "gdbsupport/environ.h"
Add RAII class for blocking gdb signals This adds configury support and an RAII class that can be used to temporarily block signals that are used by gdb. (This class is not used in this patch, but it split out for easier review.) The idea of this patch is that these signals should only be delivered to the main thread. So, when creating a background thread, they are temporarily blocked; the blocked state is inherited by the new thread. The sigprocmask man page says: The use of sigprocmask() is unspecified in a multithreaded process; see pthread_sigmask(3). This patch changes gdb to use pthread_sigmask when appropriate, by introducing a convenience define. I've updated gdbserver as well, because I had to touch gdbsupport, and because the threading patches will make it link against the thread library. I chose not to touch the NTO code, because I don't know anything about that platform and because I cannot test it. Finally, this modifies an existing spot in the Guile layer to use the new facility. gdb/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * gdbsupport/signals-state-save-restore.c (original_signal_mask): Remove comment. (save_original_signals_state, restore_original_signals_state): Use gdb_sigmask. * linux-nat.c (block_child_signals, restore_child_signals_mask) (_initialize_linux_nat): Use gdb_sigmask. * guile/guile.c (_initialize_guile): Use block_signals. * Makefile.in (HFILES_NO_SRCDIR): Add gdb-sigmask.h. * gdbsupport/gdb-sigmask.h: New file. * event-top.c (async_sigtstp_handler): Use gdb_sigmask. * cp-support.c (gdb_demangle): Use gdb_sigmask. * gdbsupport/common.m4 (GDB_AC_COMMON): Check for pthread_sigmask. * configure, config.in: Rebuild. * gdbsupport/block-signals.h: New file. gdb/gdbserver/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * remote-utils.c (block_unblock_async_io): Use gdb_sigmask. * linux-low.c (linux_wait_for_event_filtered, linux_async): Use gdb_sigmask. * configure, config.in: Rebuild. Change-Id: If3f37dc57dd859c226e9e4d79458a0514746e8c6
2019-09-29 16:50:15 +02:00
#include "gdbsupport/gdb-sigmask.h"
Rename common to gdbsupport This is the next patch in the ongoing series to move gdbsever to the top level. This patch just renames the "common" directory. The idea is to do this move in two parts: first rename the directory (this patch), then move the directory to the top. This approach makes the patches a bit more tractable. I chose the name "gdbsupport" for the directory. However, as this patch was largely written by sed, we could pick a new name without too much difficulty. Tested by the buildbot. gdb/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * contrib/ari/gdb_ari.sh: Change common to gdbsupport. * configure: Rebuild. * configure.ac: Change common to gdbsupport. * gdbsupport: Rename from common. * acinclude.m4: Change common to gdbsupport. * Makefile.in (CONFIG_SRC_SUBDIR, COMMON_SFILES) (HFILES_NO_SRCDIR, stamp-version, ALLDEPFILES): Change common to gdbsupport. * aarch64-tdep.c, ada-lang.c, ada-lang.h, agent.c, alloc.c, amd64-darwin-tdep.c, amd64-dicos-tdep.c, amd64-fbsd-nat.c, amd64-fbsd-tdep.c, amd64-linux-nat.c, amd64-linux-tdep.c, amd64-nbsd-tdep.c, amd64-obsd-tdep.c, amd64-sol2-tdep.c, amd64-tdep.c, amd64-windows-tdep.c, arch-utils.c, arch/aarch64-insn.c, arch/aarch64.c, arch/aarch64.h, arch/amd64.c, arch/amd64.h, arch/arm-get-next-pcs.c, arch/arm-linux.c, arch/arm.c, arch/i386.c, arch/i386.h, arch/ppc-linux-common.c, arch/riscv.c, arch/riscv.h, arch/tic6x.c, arm-tdep.c, auto-load.c, auxv.c, ax-gdb.c, ax-general.c, ax.h, breakpoint.c, breakpoint.h, btrace.c, btrace.h, build-id.c, build-id.h, c-lang.h, charset.c, charset.h, cli/cli-cmds.c, cli/cli-cmds.h, cli/cli-decode.c, cli/cli-dump.c, cli/cli-option.h, cli/cli-script.c, coff-pe-read.c, command.h, compile/compile-c-support.c, compile/compile-c.h, compile/compile-cplus-symbols.c, compile/compile-cplus-types.c, compile/compile-cplus.h, compile/compile-loc2c.c, compile/compile.c, completer.c, completer.h, contrib/ari/gdb_ari.sh, corefile.c, corelow.c, cp-support.c, cp-support.h, cp-valprint.c, csky-tdep.c, ctf.c, darwin-nat.c, debug.c, defs.h, disasm-selftests.c, disasm.c, disasm.h, dtrace-probe.c, dwarf-index-cache.c, dwarf-index-cache.h, dwarf-index-write.c, dwarf2-frame.c, dwarf2expr.c, dwarf2loc.c, dwarf2read.c, event-loop.c, event-top.c, exceptions.c, exec.c, extension.h, fbsd-nat.c, features/aarch64-core.c, features/aarch64-fpu.c, features/aarch64-pauth.c, features/aarch64-sve.c, features/i386/32bit-avx.c, features/i386/32bit-avx512.c, features/i386/32bit-core.c, features/i386/32bit-linux.c, features/i386/32bit-mpx.c, features/i386/32bit-pkeys.c, features/i386/32bit-segments.c, features/i386/32bit-sse.c, features/i386/64bit-avx.c, features/i386/64bit-avx512.c, features/i386/64bit-core.c, features/i386/64bit-linux.c, features/i386/64bit-mpx.c, features/i386/64bit-pkeys.c, features/i386/64bit-segments.c, features/i386/64bit-sse.c, features/i386/x32-core.c, features/riscv/32bit-cpu.c, features/riscv/32bit-csr.c, features/riscv/32bit-fpu.c, features/riscv/64bit-cpu.c, features/riscv/64bit-csr.c, features/riscv/64bit-fpu.c, features/tic6x-c6xp.c, features/tic6x-core.c, features/tic6x-gp.c, filename-seen-cache.h, findcmd.c, findvar.c, fork-child.c, gcore.c, gdb_bfd.c, gdb_bfd.h, gdb_proc_service.h, gdb_regex.c, gdb_select.h, gdb_usleep.c, gdbarch-selftests.c, gdbthread.h, gdbtypes.h, gnu-nat.c, go32-nat.c, guile/guile.c, guile/scm-ports.c, guile/scm-safe-call.c, guile/scm-type.c, i386-fbsd-nat.c, i386-fbsd-tdep.c, i386-go32-tdep.c, i386-linux-nat.c, i386-linux-tdep.c, i386-tdep.c, i387-tdep.c, ia64-libunwind-tdep.c, ia64-linux-nat.c, inf-child.c, inf-ptrace.c, infcall.c, infcall.h, infcmd.c, inferior-iter.h, inferior.c, inferior.h, inflow.c, inflow.h, infrun.c, infrun.h, inline-frame.c, language.h, linespec.c, linux-fork.c, linux-nat.c, linux-tdep.c, linux-thread-db.c, location.c, machoread.c, macrotab.h, main.c, maint.c, maint.h, memattr.c, memrange.h, mi/mi-cmd-break.h, mi/mi-cmd-env.c, mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-interp.c, mi/mi-main.c, mi/mi-parse.h, minsyms.c, mips-linux-tdep.c, namespace.h, nat/aarch64-linux-hw-point.c, nat/aarch64-linux-hw-point.h, nat/aarch64-linux.c, nat/aarch64-sve-linux-ptrace.c, nat/amd64-linux-siginfo.c, nat/fork-inferior.c, nat/linux-btrace.c, nat/linux-btrace.h, nat/linux-namespaces.c, nat/linux-nat.h, nat/linux-osdata.c, nat/linux-personality.c, nat/linux-procfs.c, nat/linux-ptrace.c, nat/linux-ptrace.h, nat/linux-waitpid.c, nat/mips-linux-watch.c, nat/mips-linux-watch.h, nat/ppc-linux.c, nat/x86-dregs.c, nat/x86-dregs.h, nat/x86-linux-dregs.c, nat/x86-linux.c, nto-procfs.c, nto-tdep.c, objfile-flags.h, objfiles.c, objfiles.h, obsd-nat.c, observable.h, osdata.c, p-valprint.c, parse.c, parser-defs.h, ppc-linux-nat.c, printcmd.c, probe.c, proc-api.c, procfs.c, producer.c, progspace.h, psymtab.h, python/py-framefilter.c, python/py-inferior.c, python/py-ref.h, python/py-type.c, python/python.c, record-btrace.c, record-full.c, record.c, record.h, regcache-dump.c, regcache.c, regcache.h, remote-fileio.c, remote-fileio.h, remote-sim.c, remote.c, riscv-tdep.c, rs6000-aix-tdep.c, rust-exp.y, s12z-tdep.c, selftest-arch.c, ser-base.c, ser-event.c, ser-pipe.c, ser-tcp.c, ser-unix.c, skip.c, solib-aix.c, solib-target.c, solib.c, source-cache.c, source.c, source.h, sparc-nat.c, spu-linux-nat.c, stack.c, stap-probe.c, symfile-add-flags.h, symfile.c, symfile.h, symtab.c, symtab.h, target-descriptions.c, target-descriptions.h, target-memory.c, target.c, target.h, target/waitstatus.c, target/waitstatus.h, thread-iter.h, thread.c, tilegx-tdep.c, top.c, top.h, tracefile-tfile.c, tracefile.c, tracepoint.c, tracepoint.h, tui/tui-io.c, ui-file.c, ui-out.h, unittests/array-view-selftests.c, unittests/child-path-selftests.c, unittests/cli-utils-selftests.c, unittests/common-utils-selftests.c, unittests/copy_bitwise-selftests.c, unittests/environ-selftests.c, unittests/format_pieces-selftests.c, unittests/function-view-selftests.c, unittests/lookup_name_info-selftests.c, unittests/memory-map-selftests.c, unittests/memrange-selftests.c, unittests/mkdir-recursive-selftests.c, unittests/observable-selftests.c, unittests/offset-type-selftests.c, unittests/optional-selftests.c, unittests/parse-connection-spec-selftests.c, unittests/ptid-selftests.c, unittests/rsp-low-selftests.c, unittests/scoped_fd-selftests.c, unittests/scoped_mmap-selftests.c, unittests/scoped_restore-selftests.c, unittests/string_view-selftests.c, unittests/style-selftests.c, unittests/tracepoint-selftests.c, unittests/unpack-selftests.c, unittests/utils-selftests.c, unittests/xml-utils-selftests.c, utils.c, utils.h, valarith.c, valops.c, valprint.c, value.c, value.h, varobj.c, varobj.h, windows-nat.c, x86-linux-nat.c, xml-support.c, xml-support.h, xml-tdesc.h, xstormy16-tdep.c, xtensa-linux-nat.c, dwarf2read.h: Change common to gdbsupport. gdb/gdbserver/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * configure: Rebuild. * configure.ac: Change common to gdbsupport. * acinclude.m4: Change common to gdbsupport. * Makefile.in (SFILES, OBS, GDBREPLAY_OBS, IPA_OBJS) (version-generated.c, gdbsupport/%-ipa.o, gdbsupport/%.o): Change common to gdbsupport. * ax.c, event-loop.c, fork-child.c, gdb_proc_service.h, gdbreplay.c, gdbthread.h, hostio-errno.c, hostio.c, i387-fp.c, inferiors.c, inferiors.h, linux-aarch64-tdesc-selftest.c, linux-amd64-ipa.c, linux-i386-ipa.c, linux-low.c, linux-tic6x-low.c, linux-x86-low.c, linux-x86-tdesc-selftest.c, linux-x86-tdesc.c, lynx-i386-low.c, lynx-low.c, mem-break.h, nto-x86-low.c, regcache.c, regcache.h, remote-utils.c, server.c, server.h, spu-low.c, symbol.c, target.h, tdesc.c, tdesc.h, thread-db.c, tracepoint.c, win32-i386-low.c, win32-low.c: Change common to gdbsupport.
2019-05-06 04:29:24 +02:00
#include "gdbsupport/scoped_restore.h"
#ifndef ELFMAG0
/* Don't include <linux/elf.h> here. If it got included by gdb_proc_service.h
then ELFMAG0 will have been defined. If it didn't get included by
gdb_proc_service.h then including it will likely introduce a duplicate
definition of elf_fpregset_t. */
#include <elf.h>
#endif
#include "nat/linux-namespaces.h"
* inferior.h (disable_randomization): Declare. * infrun.c (disable_randomization): New global variable. (show_disable_randomization): New function. (set_disable_randomization): Likewise. (_initialize_infrun): Install set/show disable-randomization commands. * linux-nat.c (disable_randomization): Remove. (show_disable_randomization): Likewise. (set_disable_randomization): Likewise. (_initialize_linux_nat): No longer install set/show disable-randomization commands here. (linux_nat_supports_disable_randomization): New function. (linux_nat_add_target): Install it. * remote.c (PACKET_QDisableRandomization): New enum value. (remote_protocol_packets): Support QDisableRandomization. (_initialize_remote): Likewise. (remote_supports_disable_randomization): New function. (init_remote_ops): Install it. (extended_remote_supports_disable_randomization): New function. (init_extended_remote_ops): Install it. (extended_remote_disable_randomization): New function. (extended_remote_create_inferior_1): Call it. * target.h (struct target_ops): Add to_supports_disable_randomization. (target_supports_disable_randomization): Add prototype. * target.c (target_supports_disable_randomization): New function. (find_default_supports_disable_randomization): Likewise. (init_dummy_target): Install it. doc/ * gdb.texinfo (Starting your Program): "set disable-randomization" is no longer Linux-specific. (Remote Configuration): Document "set remote disable-randomization-packet". (General Query Packets): Document "QDisableRandomization" packet and add it to "qSupported" list. gdbserver/ * configure.ac: Check support for personality routine. * configure: Regenerate. * config.in: Likewise. * linux-low.c: Include <sys/personality.h>. Define ADDR_NO_RANDOMIZE if necessary. (linux_create_inferior): Disable address space randomization when forking inferior, if requested. (linux_supports_disable_randomization): New function. (linux_target_ops): Install it. * server.h (disable_randomization): Declare. * server.c (disable_randomization): New global variable. (handle_general_set): Handle QDisableRandomization. (handle_query): Likewise for qSupported. (main): Support --disable-randomization and --no-disable-randomization command line arguments. * target.h (struct target_ops): Add supports_disable_randomization. (target_supports_disable_randomization): New macro.
2011-10-07 14:06:48 +02:00
#ifdef HAVE_PERSONALITY
# include <sys/personality.h>
# if !HAVE_DECL_ADDR_NO_RANDOMIZE
# define ADDR_NO_RANDOMIZE 0x0040000
# endif
#endif
#ifndef O_LARGEFILE
#define O_LARGEFILE 0
#endif
#ifndef AT_HWCAP2
#define AT_HWCAP2 26
#endif
/* Some targets did not define these ptrace constants from the start,
so gdbserver defines them locally here. In the future, these may
be removed after they are added to asm/ptrace.h. */
#if !(defined(PT_TEXT_ADDR) \
|| defined(PT_DATA_ADDR) \
|| defined(PT_TEXT_END_ADDR))
#if defined(__mcoldfire__)
/* These are still undefined in 3.10 kernels. */
#define PT_TEXT_ADDR 49*4
#define PT_DATA_ADDR 50*4
#define PT_TEXT_END_ADDR 51*4
/* These are still undefined in 3.10 kernels. */
#elif defined(__TMS320C6X__)
#define PT_TEXT_ADDR (0x10000*4)
#define PT_DATA_ADDR (0x10004*4)
#define PT_TEXT_END_ADDR (0x10008*4)
#endif
#endif
#if (defined(__UCLIBC__) \
&& defined(HAS_NOMMU) \
&& defined(PT_TEXT_ADDR) \
&& defined(PT_DATA_ADDR) \
&& defined(PT_TEXT_END_ADDR))
#define SUPPORTS_READ_OFFSETS
#endif
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
#ifdef HAVE_LINUX_BTRACE
Move shared native target specific code to gdb/nat https://sourceware.org/gdb/wiki/Common describes the following directory structure: gdb/nat/ Native target backend files. Code that interfaces with the host debug API. E.g., ptrace code, Windows debug API code, procfs code should go here. gdb/target/ Host-independent, target vector specific code (target_ops). gdb/common/ All other shared code. This commit moves all native target backend files currently in gdb/common to gdb/nat. gdb/ 2014-06-20 Gary Benson <gbenson@redhat.com> * common/gdb_thread_db.h: Moved to nat. All includes updated. * common/glibc_thread_db.h: Likewise. * common/i386-cpuid.h: Likewise. * common/i386-gcc-cpuid.h: Likewise. * common/linux-btrace.h: Likewise. * common/linux-osdata.h: Likewise. * common/linux-procfs.h: Likewise. * common/linux-ptrace.h: Likewise. * common/mips-linux-watch.h: Likewise. * common/linux-btrace.c: Moved to nat. * common/linux-osdata.c: Likewise. * common/linux-procfs.c: Likewise. * common/linux-ptrace.c: Likewise. * common/mips-linux-watch.c: Likewise. * nat/gdb_thread_db.h: Moved from common. * nat/glibc_thread_db.h: Likewise. * nat/i386-cpuid.h: Likewise. * nat/i386-gcc-cpuid.h: Likewise. * nat/linux-btrace.c: Likewise. * nat/linux-btrace.h: Likewise. * nat/linux-osdata.c: Likewise. * nat/linux-osdata.h: Likewise. * nat/linux-procfs.c: Likewise. * nat/linux-procfs.h: Likewise. * nat/linux-ptrace.c: Likewise. * nat/linux-ptrace.h: Likewise. * nat/mips-linux-watch.c: Likewise. * nat/mips-linux-watch.h: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Reflect new locations. (object file files): Reordered. * gdb/copyright.py (EXCLUDE_LIST): Reflect new location of glibc_thread_db.h. gdb/gdbserver/ 2014-06-20 Gary Benson <gbenson@redhat.com> * Makefile.in (SFILES): Update locations for files moved from common to nat. (object file files): Reordered. gdb/testsuite/ 2014-06-20 Gary Benson <gbenson@redhat.com> * gdb.arch/i386-avx.exp: Fix include file location. * gdb.arch/i386-sse.exp: Likewise.
2014-06-19 15:46:38 +02:00
# include "nat/linux-btrace.h"
Rename common to gdbsupport This is the next patch in the ongoing series to move gdbsever to the top level. This patch just renames the "common" directory. The idea is to do this move in two parts: first rename the directory (this patch), then move the directory to the top. This approach makes the patches a bit more tractable. I chose the name "gdbsupport" for the directory. However, as this patch was largely written by sed, we could pick a new name without too much difficulty. Tested by the buildbot. gdb/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * contrib/ari/gdb_ari.sh: Change common to gdbsupport. * configure: Rebuild. * configure.ac: Change common to gdbsupport. * gdbsupport: Rename from common. * acinclude.m4: Change common to gdbsupport. * Makefile.in (CONFIG_SRC_SUBDIR, COMMON_SFILES) (HFILES_NO_SRCDIR, stamp-version, ALLDEPFILES): Change common to gdbsupport. * aarch64-tdep.c, ada-lang.c, ada-lang.h, agent.c, alloc.c, amd64-darwin-tdep.c, amd64-dicos-tdep.c, amd64-fbsd-nat.c, amd64-fbsd-tdep.c, amd64-linux-nat.c, amd64-linux-tdep.c, amd64-nbsd-tdep.c, amd64-obsd-tdep.c, amd64-sol2-tdep.c, amd64-tdep.c, amd64-windows-tdep.c, arch-utils.c, arch/aarch64-insn.c, arch/aarch64.c, arch/aarch64.h, arch/amd64.c, arch/amd64.h, arch/arm-get-next-pcs.c, arch/arm-linux.c, arch/arm.c, arch/i386.c, arch/i386.h, arch/ppc-linux-common.c, arch/riscv.c, arch/riscv.h, arch/tic6x.c, arm-tdep.c, auto-load.c, auxv.c, ax-gdb.c, ax-general.c, ax.h, breakpoint.c, breakpoint.h, btrace.c, btrace.h, build-id.c, build-id.h, c-lang.h, charset.c, charset.h, cli/cli-cmds.c, cli/cli-cmds.h, cli/cli-decode.c, cli/cli-dump.c, cli/cli-option.h, cli/cli-script.c, coff-pe-read.c, command.h, compile/compile-c-support.c, compile/compile-c.h, compile/compile-cplus-symbols.c, compile/compile-cplus-types.c, compile/compile-cplus.h, compile/compile-loc2c.c, compile/compile.c, completer.c, completer.h, contrib/ari/gdb_ari.sh, corefile.c, corelow.c, cp-support.c, cp-support.h, cp-valprint.c, csky-tdep.c, ctf.c, darwin-nat.c, debug.c, defs.h, disasm-selftests.c, disasm.c, disasm.h, dtrace-probe.c, dwarf-index-cache.c, dwarf-index-cache.h, dwarf-index-write.c, dwarf2-frame.c, dwarf2expr.c, dwarf2loc.c, dwarf2read.c, event-loop.c, event-top.c, exceptions.c, exec.c, extension.h, fbsd-nat.c, features/aarch64-core.c, features/aarch64-fpu.c, features/aarch64-pauth.c, features/aarch64-sve.c, features/i386/32bit-avx.c, features/i386/32bit-avx512.c, features/i386/32bit-core.c, features/i386/32bit-linux.c, features/i386/32bit-mpx.c, features/i386/32bit-pkeys.c, features/i386/32bit-segments.c, features/i386/32bit-sse.c, features/i386/64bit-avx.c, features/i386/64bit-avx512.c, features/i386/64bit-core.c, features/i386/64bit-linux.c, features/i386/64bit-mpx.c, features/i386/64bit-pkeys.c, features/i386/64bit-segments.c, features/i386/64bit-sse.c, features/i386/x32-core.c, features/riscv/32bit-cpu.c, features/riscv/32bit-csr.c, features/riscv/32bit-fpu.c, features/riscv/64bit-cpu.c, features/riscv/64bit-csr.c, features/riscv/64bit-fpu.c, features/tic6x-c6xp.c, features/tic6x-core.c, features/tic6x-gp.c, filename-seen-cache.h, findcmd.c, findvar.c, fork-child.c, gcore.c, gdb_bfd.c, gdb_bfd.h, gdb_proc_service.h, gdb_regex.c, gdb_select.h, gdb_usleep.c, gdbarch-selftests.c, gdbthread.h, gdbtypes.h, gnu-nat.c, go32-nat.c, guile/guile.c, guile/scm-ports.c, guile/scm-safe-call.c, guile/scm-type.c, i386-fbsd-nat.c, i386-fbsd-tdep.c, i386-go32-tdep.c, i386-linux-nat.c, i386-linux-tdep.c, i386-tdep.c, i387-tdep.c, ia64-libunwind-tdep.c, ia64-linux-nat.c, inf-child.c, inf-ptrace.c, infcall.c, infcall.h, infcmd.c, inferior-iter.h, inferior.c, inferior.h, inflow.c, inflow.h, infrun.c, infrun.h, inline-frame.c, language.h, linespec.c, linux-fork.c, linux-nat.c, linux-tdep.c, linux-thread-db.c, location.c, machoread.c, macrotab.h, main.c, maint.c, maint.h, memattr.c, memrange.h, mi/mi-cmd-break.h, mi/mi-cmd-env.c, mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-interp.c, mi/mi-main.c, mi/mi-parse.h, minsyms.c, mips-linux-tdep.c, namespace.h, nat/aarch64-linux-hw-point.c, nat/aarch64-linux-hw-point.h, nat/aarch64-linux.c, nat/aarch64-sve-linux-ptrace.c, nat/amd64-linux-siginfo.c, nat/fork-inferior.c, nat/linux-btrace.c, nat/linux-btrace.h, nat/linux-namespaces.c, nat/linux-nat.h, nat/linux-osdata.c, nat/linux-personality.c, nat/linux-procfs.c, nat/linux-ptrace.c, nat/linux-ptrace.h, nat/linux-waitpid.c, nat/mips-linux-watch.c, nat/mips-linux-watch.h, nat/ppc-linux.c, nat/x86-dregs.c, nat/x86-dregs.h, nat/x86-linux-dregs.c, nat/x86-linux.c, nto-procfs.c, nto-tdep.c, objfile-flags.h, objfiles.c, objfiles.h, obsd-nat.c, observable.h, osdata.c, p-valprint.c, parse.c, parser-defs.h, ppc-linux-nat.c, printcmd.c, probe.c, proc-api.c, procfs.c, producer.c, progspace.h, psymtab.h, python/py-framefilter.c, python/py-inferior.c, python/py-ref.h, python/py-type.c, python/python.c, record-btrace.c, record-full.c, record.c, record.h, regcache-dump.c, regcache.c, regcache.h, remote-fileio.c, remote-fileio.h, remote-sim.c, remote.c, riscv-tdep.c, rs6000-aix-tdep.c, rust-exp.y, s12z-tdep.c, selftest-arch.c, ser-base.c, ser-event.c, ser-pipe.c, ser-tcp.c, ser-unix.c, skip.c, solib-aix.c, solib-target.c, solib.c, source-cache.c, source.c, source.h, sparc-nat.c, spu-linux-nat.c, stack.c, stap-probe.c, symfile-add-flags.h, symfile.c, symfile.h, symtab.c, symtab.h, target-descriptions.c, target-descriptions.h, target-memory.c, target.c, target.h, target/waitstatus.c, target/waitstatus.h, thread-iter.h, thread.c, tilegx-tdep.c, top.c, top.h, tracefile-tfile.c, tracefile.c, tracepoint.c, tracepoint.h, tui/tui-io.c, ui-file.c, ui-out.h, unittests/array-view-selftests.c, unittests/child-path-selftests.c, unittests/cli-utils-selftests.c, unittests/common-utils-selftests.c, unittests/copy_bitwise-selftests.c, unittests/environ-selftests.c, unittests/format_pieces-selftests.c, unittests/function-view-selftests.c, unittests/lookup_name_info-selftests.c, unittests/memory-map-selftests.c, unittests/memrange-selftests.c, unittests/mkdir-recursive-selftests.c, unittests/observable-selftests.c, unittests/offset-type-selftests.c, unittests/optional-selftests.c, unittests/parse-connection-spec-selftests.c, unittests/ptid-selftests.c, unittests/rsp-low-selftests.c, unittests/scoped_fd-selftests.c, unittests/scoped_mmap-selftests.c, unittests/scoped_restore-selftests.c, unittests/string_view-selftests.c, unittests/style-selftests.c, unittests/tracepoint-selftests.c, unittests/unpack-selftests.c, unittests/utils-selftests.c, unittests/xml-utils-selftests.c, utils.c, utils.h, valarith.c, valops.c, valprint.c, value.c, value.h, varobj.c, varobj.h, windows-nat.c, x86-linux-nat.c, xml-support.c, xml-support.h, xml-tdesc.h, xstormy16-tdep.c, xtensa-linux-nat.c, dwarf2read.h: Change common to gdbsupport. gdb/gdbserver/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * configure: Rebuild. * configure.ac: Change common to gdbsupport. * acinclude.m4: Change common to gdbsupport. * Makefile.in (SFILES, OBS, GDBREPLAY_OBS, IPA_OBJS) (version-generated.c, gdbsupport/%-ipa.o, gdbsupport/%.o): Change common to gdbsupport. * ax.c, event-loop.c, fork-child.c, gdb_proc_service.h, gdbreplay.c, gdbthread.h, hostio-errno.c, hostio.c, i387-fp.c, inferiors.c, inferiors.h, linux-aarch64-tdesc-selftest.c, linux-amd64-ipa.c, linux-i386-ipa.c, linux-low.c, linux-tic6x-low.c, linux-x86-low.c, linux-x86-tdesc-selftest.c, linux-x86-tdesc.c, lynx-i386-low.c, lynx-low.c, mem-break.h, nto-x86-low.c, regcache.c, regcache.h, remote-utils.c, server.c, server.h, spu-low.c, symbol.c, target.h, tdesc.c, tdesc.h, thread-db.c, tracepoint.c, win32-i386-low.c, win32-low.c: Change common to gdbsupport.
2019-05-06 04:29:24 +02:00
# include "gdbsupport/btrace-common.h"
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
#endif
#ifndef HAVE_ELF32_AUXV_T
/* Copied from glibc's elf.h. */
typedef struct
{
uint32_t a_type; /* Entry type */
union
{
uint32_t a_val; /* Integer value */
/* We use to have pointer elements added here. We cannot do that,
though, since it does not work when using 32-bit definitions
on 64-bit platforms and vice versa. */
} a_un;
} Elf32_auxv_t;
#endif
#ifndef HAVE_ELF64_AUXV_T
/* Copied from glibc's elf.h. */
typedef struct
{
uint64_t a_type; /* Entry type */
union
{
uint64_t a_val; /* Integer value */
/* We use to have pointer elements added here. We cannot do that,
though, since it does not work when using 32-bit definitions
on 64-bit platforms and vice versa. */
} a_un;
} Elf64_auxv_t;
#endif
/* Does the current host support PTRACE_GETREGSET? */
int have_ptrace_getregset = -1;
/* LWP accessors. */
/* See nat/linux-nat.h. */
ptid_t
ptid_of_lwp (struct lwp_info *lwp)
{
return ptid_of (get_lwp_thread (lwp));
}
/* See nat/linux-nat.h. */
2015-03-24 15:05:44 +01:00
void
lwp_set_arch_private_info (struct lwp_info *lwp,
struct arch_lwp_info *info)
{
lwp->arch_private = info;
}
/* See nat/linux-nat.h. */
struct arch_lwp_info *
lwp_arch_private_info (struct lwp_info *lwp)
{
return lwp->arch_private;
}
/* See nat/linux-nat.h. */
int
lwp_is_stopped (struct lwp_info *lwp)
{
return lwp->stopped;
}
/* See nat/linux-nat.h. */
enum target_stop_reason
lwp_stop_reason (struct lwp_info *lwp)
{
return lwp->stop_reason;
}
/* See nat/linux-nat.h. */
int
lwp_is_stepping (struct lwp_info *lwp)
{
return lwp->stepping;
}
/* A list of all unknown processes which receive stop signals. Some
other process will presumably claim each of these as forked
children momentarily. */
* inferiors.c (change_inferior_id): Delete. (add_pid_to_list, pull_pid_from_list): New. * linux-low.c (PTRACE_SETOPTIONS, PTRACE_GETEVENTMSG) (PTRACE_O_TRACESYSGOOD, PTRACE_O_TRACEFORK, PTRACE_O_TRACEVFORK) (PTRACE_O_TRACECLONE, PTRACE_O_TRACEEXEC, PTRACE_O_TRACEVFORKDONE) (PTRACE_O_TRACEEXIT, PTRACE_EVENT_FORK, PTRACE_EVENT_VFORK) (PTRACE_EVENT_CLONE, PTRACE_EVENT_EXEC, PTRACE_EVENT_VFORK_DONE) (PTRACE_EVENT_EXIT, __WALL): Provide default definitions. (stopped_pids, thread_db_active, must_set_ptrace_flags): New variables. (using_threads): Always set to 1. (handle_extended_wait): New. (add_process): Do not set TID. (linux_create_inferior): Set must_set_ptrace_flags. (linux_attach_lwp): Remove TID argument. Do not check using_threads. Use PTRACE_SETOPTIONS. Call new_thread_notify. Update all callers. (linux_thread_alive): Rename TID argument to LWPID. (linux_wait_for_process): Handle unknown processes. Do not use TID. (linux_wait_for_event): Do not use TID or check using_threads. Update call to dead_thread_notify. Call handle_extended_wait. (linux_create_inferior): Use PTRACE_SETOPTIONS. (send_sigstop): Delete sigstop_sent. (wait_for_sigstop): Avoid TID. (linux_supports_tracefork_flag, linux_tracefork_child, my_waitpid) (linux_test_for_tracefork): New. (linux_lookup_signals): Use thread_db_active and linux_supports_tracefork_flag. (initialize_low): Use thread_db_active and linux_test_for_tracefork. * linux-low.h (get_process_thread): Avoid TID. (struct process_ifo): Move thread_known and tid to the end. Remove sigstop_sent. (linux_attach_lwp, thread_db_init): Update prototypes. * server.h (change_inferior_id): Delete prototype. (add_pid_to_list, pull_pid_from_list): New prototypes. * thread-db.c (thread_db_use_events): New. (find_first_thread): Rename to... (find_one_thread): ...this. Update callers and messages. Do not call fatal. Check thread_db_use_events. Do not call change_inferior_id or new_thread_notify. (maybe_attach_thread): Update. Do not call new_thread_notify. (thread_db_init): Set thread_db_use_events. Check use_events. * utils.c (fatal, warning): Correct message prefix.
2007-10-23 22:05:03 +02:00
struct simple_pid_list
{
/* The process ID. */
int pid;
/* The status as reported by waitpid. */
int status;
/* Next in chain. */
struct simple_pid_list *next;
};
struct simple_pid_list *stopped_pids;
/* Trivial list manipulation functions to keep track of a list of new
stopped processes. */
static void
add_to_pid_list (struct simple_pid_list **listp, int pid, int status)
{
Replace some xmalloc-family functions with XNEW-family ones This patch is part of the make-gdb-buildable-in-C++ effort. The idea is to change some calls to the xmalloc family of functions to calls to the equivalents in the XNEW family. This avoids adding an explicit cast, so it keeps the code a bit more readable. Some of them also map relatively well to a C++ equivalent (XNEW (struct foo) -> new foo), so it will be possible to do scripted replacements if needed. I only changed calls that were obviously allocating memory for one or multiple "objects". Allocation of variable sizes (such as strings or buffer handling) will be for later (and won't use XNEW). - xmalloc (sizeof (struct foo)) -> XNEW (struct foo) - xmalloc (num * sizeof (struct foo)) -> XNEWVEC (struct foo, num) - xcalloc (1, sizeof (struct foo)) -> XCNEW (struct foo) - xcalloc (num, sizeof (struct foo)) -> XCNEWVEC (struct foo, num) - xrealloc (p, num * sizeof (struct foo) -> XRESIZEVEC (struct foo, p, num) - obstack_alloc (ob, sizeof (struct foo)) -> XOBNEW (ob, struct foo) - obstack_alloc (ob, num * sizeof (struct foo)) -> XOBNEWVEC (ob, struct foo, num) - alloca (sizeof (struct foo)) -> XALLOCA (struct foo) - alloca (num * sizeof (struct foo)) -> XALLOCAVEC (struct foo, num) Some instances of xmalloc followed by memset to zero the buffer were replaced by XCNEW or XCNEWVEC. I regtested on x86-64, Ubuntu 14.04, but the patch touches many architecture-specific files. For those I'll have to rely on the buildbot or people complaining that I broke their gdb. gdb/ChangeLog: * aarch64-linux-nat.c (aarch64_add_process): Likewise. * aarch64-tdep.c (aarch64_gdbarch_init): Likewise. * ada-exp.y (write_ambiguous_var): Likewise. * ada-lang.c (resolve_subexp): Likewise. (user_select_syms): Likewise. (assign_aggregate): Likewise. (ada_evaluate_subexp): Likewise. (cache_symbol): Likewise. * addrmap.c (allocate_key): Likewise. (addrmap_create_mutable): Likewise. * aix-thread.c (sync_threadlists): Likewise. * alpha-tdep.c (alpha_push_dummy_call): Likewise. (alpha_gdbarch_init): Likewise. * amd64-windows-tdep.c (amd64_windows_push_arguments): Likewise. * arm-linux-nat.c (arm_linux_add_process): Likewise. * arm-linux-tdep.c (arm_linux_displaced_step_copy_insn): Likewise. * arm-tdep.c (push_stack_item): Likewise. (arm_displaced_step_copy_insn): Likewise. (arm_gdbarch_init): Likewise. (_initialize_arm_tdep): Likewise. * avr-tdep.c (push_stack_item): Likewise. * ax-general.c (new_agent_expr): Likewise. * block.c (block_initialize_namespace): Likewise. * breakpoint.c (alloc_counted_command_line): Likewise. (update_dprintf_command_list): Likewise. (parse_breakpoint_sals): Likewise. (decode_static_tracepoint_spec): Likewise. (until_break_command): Likewise. (clear_command): Likewise. (update_global_location_list): Likewise. (get_breakpoint_objfile_data) Likewise. * btrace.c (ftrace_new_function): Likewise. (btrace_set_insn_history): Likewise. (btrace_set_call_history): Likewise. * buildsym.c (add_symbol_to_list): Likewise. (record_pending_block): Likewise. (start_subfile): Likewise. (start_buildsym_compunit): Likewise. (push_subfile): Likewise. (end_symtab_get_static_block): Likewise. (buildsym_init): Likewise. * cli/cli-cmds.c (source_command): Likewise. * cli/cli-decode.c (add_cmd): Likewise. * cli/cli-script.c (build_command_line): Likewise. (setup_user_args): Likewise. (realloc_body_list): Likewise. (process_next_line): Likewise. (copy_command_lines): Likewise. * cli/cli-setshow.c (do_set_command): Likewise. * coff-pe-read.c (read_pe_exported_syms): Likewise. * coffread.c (coff_locate_sections): Likewise. (coff_symtab_read): Likewise. (coff_read_struct_type): Likewise. * common/cleanups.c (make_my_cleanup2): Likewise. * common/common-exceptions.c (throw_it): Likewise. * common/filestuff.c (make_cleanup_close): Likewise. * common/format.c (parse_format_string): Likewise. * common/queue.h (DEFINE_QUEUE_P): Likewise. * compile/compile-object-load.c (munmap_list_add): Likewise. (compile_object_load): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * compile/compile.c (append_args): Likewise. * corefile.c (specify_exec_file_hook): Likewise. * cp-support.c (make_symbol_overload_list): Likewise. * cris-tdep.c (push_stack_item): Likewise. (cris_gdbarch_init): Likewise. * ctf.c (ctf_trace_file_writer_new): Likewise. * dbxread.c (init_header_files): Likewise. (add_new_header_file): Likewise. (init_bincl_list): Likewise. (dbx_end_psymtab): Likewise. (start_psymtab): Likewise. (dbx_end_psymtab): Likewise. * dcache.c (dcache_init): Likewise. * dictionary.c (dict_create_hashed): Likewise. (dict_create_hashed_expandable): Likewise. (dict_create_linear): Likewise. (dict_create_linear_expandable): Likewise. * dtrace-probe.c (dtrace_process_dof_probe): Likewise. * dummy-frame.c (register_dummy_frame_dtor): Likewise. * dwarf2-frame-tailcall.c (cache_new_ref1): Likewise. * dwarf2-frame.c (dwarf2_build_frame_info): Likewise. (decode_frame_entry_1): Likewise. * dwarf2expr.c (new_dwarf_expr_context): Likewise. * dwarf2loc.c (dwarf2_compile_expr_to_ax): Likewise. * dwarf2read.c (dwarf2_has_info): Likewise. (create_signatured_type_table_from_index): Likewise. (dwarf2_read_index): Likewise. (dw2_get_file_names_reader): Likewise. (create_all_type_units): Likewise. (read_cutu_die_from_dwo): Likewise. (init_tu_and_read_dwo_dies): Likewise. (init_cutu_and_read_dies): Likewise. (create_all_comp_units): Likewise. (queue_comp_unit): Likewise. (inherit_abstract_dies): Likewise. (read_call_site_scope): Likewise. (dwarf2_add_field): Likewise. (dwarf2_add_typedef): Likewise. (dwarf2_add_member_fn): Likewise. (attr_to_dynamic_prop): Likewise. (abbrev_table_alloc_abbrev): Likewise. (abbrev_table_read_table): Likewise. (add_include_dir): Likewise. (add_file_name): Likewise. (dwarf_decode_line_header): Likewise. (dwarf2_const_value_attr): Likewise. (dwarf_alloc_block): Likewise. (parse_macro_definition): Likewise. (set_die_type): Likewise. (write_psymtabs_to_index): Likewise. (create_cus_from_index): Likewise. (dwarf2_create_include_psymtab): Likewise. (process_psymtab_comp_unit_reader): Likewise. (build_type_psymtab_dependencies): Likewise. (read_comp_units_from_section): Likewise. (compute_compunit_symtab_includes): Likewise. (create_dwo_unit_in_dwp_v1): Likewise. (create_dwo_unit_in_dwp_v2): Likewise. (read_func_scope): Likewise. (process_structure_scope): Likewise. (mark_common_block_symbol_computed): Likewise. (load_partial_dies): Likewise. (dwarf2_symbol_mark_computed): Likewise. * elfread.c (elf_symfile_segments): Likewise. (elf_read_minimal_symbols): Likewise. * environ.c (make_environ): Likewise. * eval.c (evaluate_subexp_standard): Likewise. * event-loop.c (create_file_handler): Likewise. (create_async_signal_handler): Likewise. (create_async_event_handler): Likewise. (create_timer): Likewise. * exec.c (build_section_table): Likewise. * fbsd-nat.c (fbsd_remember_child): Likewise. * fork-child.c (fork_inferior): Likewise. * frv-tdep.c (new_variant): Likewise. * gdbarch.sh (gdbarch_alloc): Likewise. (append_name): Likewise. * gdbtypes.c (rank_function): Likewise. (copy_type_recursive): Likewise. (add_dyn_prop): Likewise. * gnu-nat.c (make_proc): Likewise. (make_inf): Likewise. (gnu_write_inferior): Likewise. * gnu-v3-abi.c (build_gdb_vtable_type): Likewise. (build_std_type_info_type): Likewise. * guile/scm-param.c (compute_enum_list): Likewise. * guile/scm-utils.c (gdbscm_parse_function_args): Likewise. * guile/scm-value.c (gdbscm_value_call): Likewise. * h8300-tdep.c (h8300_gdbarch_init): Likewise. * hppa-tdep.c (hppa_init_objfile_priv_data): Likewise. (read_unwind_info): Likewise. * ia64-tdep.c (ia64_gdbarch_init): Likewise. * infcall.c (dummy_frame_context_saver_setup): Likewise. (call_function_by_hand_dummy): Likewise. * infcmd.c (step_once): Likewise. (finish_forward): Likewise. (attach_command): Likewise. (notice_new_inferior): Likewise. * inferior.c (add_inferior_silent): Likewise. * infrun.c (add_displaced_stepping_state): Likewise. (save_infcall_control_state): Likewise. (save_inferior_ptid): Likewise. (_initialize_infrun): Likewise. * jit.c (bfd_open_from_target_memory): Likewise. (jit_gdbarch_data_init): Likewise. * language.c (add_language): Likewise. * linespec.c (decode_line_2): Likewise. * linux-nat.c (add_to_pid_list): Likewise. (add_initial_lwp): Likewise. * linux-thread-db.c (add_thread_db_info): Likewise. (record_thread): Likewise. (info_auto_load_libthread_db): Likewise. * m32c-tdep.c (m32c_gdbarch_init): Likewise. * m68hc11-tdep.c (m68hc11_gdbarch_init): Likewise. * m68k-tdep.c (m68k_gdbarch_init): Likewise. * m88k-tdep.c (m88k_analyze_prologue): Likewise. * macrocmd.c (macro_define_command): Likewise. * macroexp.c (gather_arguments): Likewise. * macroscope.c (sal_macro_scope): Likewise. * macrotab.c (new_macro_table): Likewise. * mdebugread.c (push_parse_stack): Likewise. (parse_partial_symbols): Likewise. (parse_symbol): Likewise. (psymtab_to_symtab_1): Likewise. (new_block): Likewise. (new_psymtab): Likewise. (mdebug_build_psymtabs): Likewise. (add_pending): Likewise. (elfmdebug_build_psymtabs): Likewise. * mep-tdep.c (mep_gdbarch_init): Likewise. * mi/mi-main.c (mi_execute_command): Likewise. * mi/mi-parse.c (mi_parse_argv): Likewise. * minidebug.c (lzma_open): Likewise. * minsyms.c (terminate_minimal_symbol_table): Likewise. * mips-linux-nat.c (mips_linux_insert_watchpoint): Likewise. * mips-tdep.c (mips_gdbarch_init): Likewise. * mn10300-tdep.c (mn10300_gdbarch_init): Likewise. * msp430-tdep.c (msp430_gdbarch_init): Likewise. * mt-tdep.c (mt_registers_info): Likewise. * nat/aarch64-linux.c (aarch64_linux_new_thread): Likewise. * nat/linux-btrace.c (linux_enable_bts): Likewise. (linux_enable_pt): Likewise. * nat/linux-osdata.c (linux_xfer_osdata_processes): Likewise. (linux_xfer_osdata_processgroups): Likewise. * nios2-tdep.c (nios2_gdbarch_init): Likewise. * nto-procfs.c (procfs_meminfo): Likewise. * objc-lang.c (start_msglist): Likewise. (selectors_info): Likewise. (classes_info): Likewise. (find_methods): Likewise. * objfiles.c (allocate_objfile): Likewise. (update_section_map): Likewise. * osabi.c (gdbarch_register_osabi): Likewise. (gdbarch_register_osabi_sniffer): Likewise. * parse.c (start_arglist): Likewise. * ppc-linux-nat.c (hwdebug_find_thread_points_by_tid): Likewise. (hwdebug_insert_point): Likewise. * printcmd.c (display_command): Likewise. (ui_printf): Likewise. * procfs.c (create_procinfo): Likewise. (load_syscalls): Likewise. (proc_get_LDT_entry): Likewise. (proc_update_threads): Likewise. * prologue-value.c (make_pv_area): Likewise. (pv_area_store): Likewise. * psymtab.c (extend_psymbol_list): Likewise. (init_psymbol_list): Likewise. (allocate_psymtab): Likewise. * python/py-inferior.c (add_thread_object): Likewise. * python/py-param.c (compute_enum_values): Likewise. * python/py-value.c (valpy_call): Likewise. * python/py-varobj.c (py_varobj_iter_next): Likewise. * python/python.c (ensure_python_env): Likewise. * record-btrace.c (record_btrace_start_replaying): Likewise. * record-full.c (record_full_reg_alloc): Likewise. (record_full_mem_alloc): Likewise. (record_full_end_alloc): Likewise. (record_full_core_xfer_partial): Likewise. * regcache.c (get_thread_arch_aspace_regcache): Likewise. * remote-fileio.c (remote_fileio_init_fd_map): Likewise. * remote-notif.c (remote_notif_state_allocate): Likewise. * remote.c (demand_private_info): Likewise. (remote_notif_stop_alloc_reply): Likewise. (remote_enable_btrace): Likewise. * reverse.c (save_bookmark_command): Likewise. * rl78-tdep.c (rl78_gdbarch_init): Likewise. * rx-tdep.c (rx_gdbarch_init): Likewise. * s390-linux-nat.c (s390_insert_watchpoint): Likewise. * ser-go32.c (dos_get_tty_state): Likewise. (dos_copy_tty_state): Likewise. * ser-mingw.c (ser_windows_open): Likewise. (ser_console_wait_handle): Likewise. (ser_console_get_tty_state): Likewise. (make_pipe_state): Likewise. (net_windows_open): Likewise. * ser-unix.c (hardwire_get_tty_state): Likewise. (hardwire_copy_tty_state): Likewise. * solib-aix.c (solib_aix_new_lm_info): Likewise. * solib-dsbt.c (dsbt_current_sos): Likewise. (dsbt_relocate_main_executable): Likewise. * solib-frv.c (frv_current_sos): Likewise. (frv_relocate_main_executable): Likewise. * solib-spu.c (spu_bfd_fopen): Likewise. * solib-svr4.c (lm_info_read): Likewise. (svr4_copy_library_list): Likewise. (svr4_default_sos): Likewise. * source.c (find_source_lines): Likewise. (line_info): Likewise. (add_substitute_path_rule): Likewise. * spu-linux-nat.c (spu_bfd_open): Likewise. * spu-tdep.c (info_spu_dma_cmdlist): Likewise. * stabsread.c (dbx_lookup_type): Likewise. (read_type): Likewise. (read_member_functions): Likewise. (read_struct_fields): Likewise. (read_baseclasses): Likewise. (read_args): Likewise. (_initialize_stabsread): Likewise. * stack.c (func_command): Likewise. * stap-probe.c (handle_stap_probe): Likewise. * symfile.c (addrs_section_sort): Likewise. (addr_info_make_relative): Likewise. (load_section_callback): Likewise. (add_symbol_file_command): Likewise. (init_filename_language_table): Likewise. * symtab.c (create_filename_seen_cache): Likewise. (sort_search_symbols_remove_dups): Likewise. (search_symbols): Likewise. * target.c (make_cleanup_restore_target_terminal): Likewise. * thread.c (new_thread): Likewise. (enable_thread_stack_temporaries): Likewise. (make_cleanup_restore_current_thread): Likewise. (thread_apply_all_command): Likewise. * tic6x-tdep.c (tic6x_gdbarch_init): Likewise. * top.c (gdb_readline_wrapper): Likewise. * tracefile-tfile.c (tfile_trace_file_writer_new): Likewise. * tracepoint.c (trace_find_line_command): Likewise. (all_tracepoint_actions_and_cleanup): Likewise. (make_cleanup_restore_current_traceframe): Likewise. (get_uploaded_tp): Likewise. (get_uploaded_tsv): Likewise. * tui/tui-data.c (tui_alloc_generic_win_info): Likewise. (tui_alloc_win_info): Likewise. (tui_alloc_content): Likewise. (tui_add_content_elements): Likewise. * tui/tui-disasm.c (tui_find_disassembly_address): Likewise. (tui_set_disassem_content): Likewise. * ui-file.c (ui_file_new): Likewise. (stdio_file_new): Likewise. (tee_file_new): Likewise. * utils.c (make_cleanup_restore_integer): Likewise. (add_internal_problem_command): Likewise. * v850-tdep.c (v850_gdbarch_init): Likewise. * valops.c (find_oload_champ): Likewise. * value.c (allocate_value_lazy): Likewise. (record_latest_value): Likewise. (create_internalvar): Likewise. * varobj.c (install_variable): Likewise. (new_variable): Likewise. (new_root_variable): Likewise. (cppush): Likewise. (_initialize_varobj): Likewise. * windows-nat.c (windows_make_so): Likewise. * x86-nat.c (x86_add_process): Likewise. * xcoffread.c (arrange_linetable): Likewise. (allocate_include_entry): Likewise. (process_linenos): Likewise. (SYMBOL_DUP): Likewise. (xcoff_start_psymtab): Likewise. (xcoff_end_psymtab): Likewise. * xml-support.c (gdb_xml_parse_attr_ulongest): Likewise. * xtensa-tdep.c (xtensa_register_type): Likewise. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. gdb/gdbserver/ChangeLog: * ax.c (gdb_parse_agent_expr): Likewise. (compile_bytecodes): Likewise. * dll.c (loaded_dll): Likewise. * event-loop.c (append_callback_event): Likewise. (create_file_handler): Likewise. (create_file_event): Likewise. * hostio.c (handle_open): Likewise. * inferiors.c (add_thread): Likewise. (add_process): Likewise. * linux-aarch64-low.c (aarch64_linux_new_process): Likewise. * linux-arm-low.c (arm_new_process): Likewise. (arm_new_thread): Likewise. * linux-low.c (add_to_pid_list): Likewise. (linux_add_process): Likewise. (handle_extended_wait): Likewise. (add_lwp): Likewise. (enqueue_one_deferred_signal): Likewise. (enqueue_pending_signal): Likewise. (linux_resume_one_lwp_throw): Likewise. (linux_resume_one_thread): Likewise. (linux_read_memory): Likewise. (linux_write_memory): Likewise. * linux-mips-low.c (mips_linux_new_process): Likewise. (mips_linux_new_thread): Likewise. (mips_add_watchpoint): Likewise. * linux-x86-low.c (initialize_low_arch): Likewise. * lynx-low.c (lynx_add_process): Likewise. * mem-break.c (set_raw_breakpoint_at): Likewise. (set_breakpoint): Likewise. (add_condition_to_breakpoint): Likewise. (add_commands_to_breakpoint): Likewise. (clone_agent_expr): Likewise. (clone_one_breakpoint): Likewise. * regcache.c (new_register_cache): Likewise. * remote-utils.c (look_up_one_symbol): Likewise. * server.c (queue_stop_reply): Likewise. (start_inferior): Likewise. (queue_stop_reply_callback): Likewise. (handle_target_event): Likewise. * spu-low.c (fetch_ppc_memory): Likewise. (store_ppc_memory): Likewise. * target.c (set_target_ops): Likewise. * thread-db.c (thread_db_load_search): Likewise. (try_thread_db_load_1): Likewise. * tracepoint.c (add_tracepoint): Likewise. (add_tracepoint_action): Likewise. (create_trace_state_variable): Likewise. (cmd_qtdpsrc): Likewise. (cmd_qtro): Likewise. (add_while_stepping_state): Likewise. * win32-low.c (child_add_thread): Likewise. (get_image_name): Likewise.
2015-08-26 23:16:07 +02:00
struct simple_pid_list *new_pid = XNEW (struct simple_pid_list);
new_pid->pid = pid;
new_pid->status = status;
new_pid->next = *listp;
*listp = new_pid;
}
static int
pull_pid_from_list (struct simple_pid_list **listp, int pid, int *statusp)
{
struct simple_pid_list **p;
for (p = listp; *p != NULL; p = &(*p)->next)
if ((*p)->pid == pid)
{
struct simple_pid_list *next = (*p)->next;
*statusp = (*p)->status;
xfree (*p);
*p = next;
return 1;
}
return 0;
}
* inferiors.c (change_inferior_id): Delete. (add_pid_to_list, pull_pid_from_list): New. * linux-low.c (PTRACE_SETOPTIONS, PTRACE_GETEVENTMSG) (PTRACE_O_TRACESYSGOOD, PTRACE_O_TRACEFORK, PTRACE_O_TRACEVFORK) (PTRACE_O_TRACECLONE, PTRACE_O_TRACEEXEC, PTRACE_O_TRACEVFORKDONE) (PTRACE_O_TRACEEXIT, PTRACE_EVENT_FORK, PTRACE_EVENT_VFORK) (PTRACE_EVENT_CLONE, PTRACE_EVENT_EXEC, PTRACE_EVENT_VFORK_DONE) (PTRACE_EVENT_EXIT, __WALL): Provide default definitions. (stopped_pids, thread_db_active, must_set_ptrace_flags): New variables. (using_threads): Always set to 1. (handle_extended_wait): New. (add_process): Do not set TID. (linux_create_inferior): Set must_set_ptrace_flags. (linux_attach_lwp): Remove TID argument. Do not check using_threads. Use PTRACE_SETOPTIONS. Call new_thread_notify. Update all callers. (linux_thread_alive): Rename TID argument to LWPID. (linux_wait_for_process): Handle unknown processes. Do not use TID. (linux_wait_for_event): Do not use TID or check using_threads. Update call to dead_thread_notify. Call handle_extended_wait. (linux_create_inferior): Use PTRACE_SETOPTIONS. (send_sigstop): Delete sigstop_sent. (wait_for_sigstop): Avoid TID. (linux_supports_tracefork_flag, linux_tracefork_child, my_waitpid) (linux_test_for_tracefork): New. (linux_lookup_signals): Use thread_db_active and linux_supports_tracefork_flag. (initialize_low): Use thread_db_active and linux_test_for_tracefork. * linux-low.h (get_process_thread): Avoid TID. (struct process_ifo): Move thread_known and tid to the end. Remove sigstop_sent. (linux_attach_lwp, thread_db_init): Update prototypes. * server.h (change_inferior_id): Delete prototype. (add_pid_to_list, pull_pid_from_list): New prototypes. * thread-db.c (thread_db_use_events): New. (find_first_thread): Rename to... (find_one_thread): ...this. Update callers and messages. Do not call fatal. Check thread_db_use_events. Do not call change_inferior_id or new_thread_notify. (maybe_attach_thread): Update. Do not call new_thread_notify. (thread_db_init): Set thread_db_use_events. Check use_events. * utils.c (fatal, warning): Correct message prefix.
2007-10-23 22:05:03 +02:00
enum stopping_threads_kind
{
/* Not stopping threads presently. */
NOT_STOPPING_THREADS,
/* Stopping threads. */
STOPPING_THREADS,
/* Stopping and suspending threads. */
STOPPING_AND_SUSPENDING_THREADS
};
/* This is set while stop_all_lwps is in effect. */
enum stopping_threads_kind stopping_threads = NOT_STOPPING_THREADS;
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
/* FIXME make into a target method? */
* inferiors.c (change_inferior_id): Delete. (add_pid_to_list, pull_pid_from_list): New. * linux-low.c (PTRACE_SETOPTIONS, PTRACE_GETEVENTMSG) (PTRACE_O_TRACESYSGOOD, PTRACE_O_TRACEFORK, PTRACE_O_TRACEVFORK) (PTRACE_O_TRACECLONE, PTRACE_O_TRACEEXEC, PTRACE_O_TRACEVFORKDONE) (PTRACE_O_TRACEEXIT, PTRACE_EVENT_FORK, PTRACE_EVENT_VFORK) (PTRACE_EVENT_CLONE, PTRACE_EVENT_EXEC, PTRACE_EVENT_VFORK_DONE) (PTRACE_EVENT_EXIT, __WALL): Provide default definitions. (stopped_pids, thread_db_active, must_set_ptrace_flags): New variables. (using_threads): Always set to 1. (handle_extended_wait): New. (add_process): Do not set TID. (linux_create_inferior): Set must_set_ptrace_flags. (linux_attach_lwp): Remove TID argument. Do not check using_threads. Use PTRACE_SETOPTIONS. Call new_thread_notify. Update all callers. (linux_thread_alive): Rename TID argument to LWPID. (linux_wait_for_process): Handle unknown processes. Do not use TID. (linux_wait_for_event): Do not use TID or check using_threads. Update call to dead_thread_notify. Call handle_extended_wait. (linux_create_inferior): Use PTRACE_SETOPTIONS. (send_sigstop): Delete sigstop_sent. (wait_for_sigstop): Avoid TID. (linux_supports_tracefork_flag, linux_tracefork_child, my_waitpid) (linux_test_for_tracefork): New. (linux_lookup_signals): Use thread_db_active and linux_supports_tracefork_flag. (initialize_low): Use thread_db_active and linux_test_for_tracefork. * linux-low.h (get_process_thread): Avoid TID. (struct process_ifo): Move thread_known and tid to the end. Remove sigstop_sent. (linux_attach_lwp, thread_db_init): Update prototypes. * server.h (change_inferior_id): Delete prototype. (add_pid_to_list, pull_pid_from_list): New prototypes. * thread-db.c (thread_db_use_events): New. (find_first_thread): Rename to... (find_one_thread): ...this. Update callers and messages. Do not call fatal. Check thread_db_use_events. Do not call change_inferior_id or new_thread_notify. (maybe_attach_thread): Update. Do not call new_thread_notify. (thread_db_init): Set thread_db_use_events. Check use_events. * utils.c (fatal, warning): Correct message prefix.
2007-10-23 22:05:03 +02:00
int using_threads = 1;
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
/* True if we're presently stabilizing threads (moving them out of
jump pads). */
static int stabilizing_threads;
Step over exit with reinsert breakpoints This patch fixes a GDBserver crash when one thread is stepping over a syscall instruction which is exit. Step-over isn't finished due to the exit, but GDBserver doesn't clean up the state of step-over, so in the wait next time, GDBserver will wait on step_over_bkpt, which is already exited, and GDBserver crashes because 'requested_child' is NULL. See gdbserver logs below, Need step over [LWP 14858]? yes, found breakpoint at 0x2aaaaad91307^M proceed_all_lwps: found thread 14858 needing a step-over^M Starting step-over on LWP 14858. Stopping all threads^M >>>> entering void stop_all_lwps(int, lwp_info*) .... <<<< exiting void stop_all_lwps(int, lwp_info*)^M Done stopping all threads for step-over.^M pc is 0x2aaaaad91307^M Writing 0f to 0x2aaaaad91307 in process 14858^M Could not find fast tracepoint jump at 0x2aaaaad91307 in list (uninserting).^M pending reinsert at 0x2aaaaad91307^M step from pc 0x2aaaaad91307^M Resuming lwp 14858 (step, signal 0, stop not expected)^M # Start step-over for LWP 14858 >>>> entering ptid_t linux_wait_1(ptid_t, target_waitstatus*, int) .... LLFE: 14858 exited. ... <<<< exiting ptid_t linux_wait_1(ptid_t, target_waitstatus*, int) # LWP 14858 exited ..... >>>> entering ptid_t linux_wait_1(ptid_t, target_waitstatus*, int)^M linux_wait_1: [<all threads>]^M step_over_bkpt set [LWP 14858.14858], doing a blocking wait # but step_over_bkpt is still LWP 14858, which is wrong The fix is to finish step-over if it is ongoing, and unsuspend other threads. Without the fix in linux-low.c, GDBserver will crash in with running gdb.base/step-over-exit.exp. gdb/gdbserver: 2016-06-17 Yao Qi <yao.qi@linaro.org> * linux-low.c (unsuspend_all_lwps): Declare. (linux_low_filter_event): If thread exited, call finish_step_over. If step-over is finished, unsuspend other threads. gdb/testsuite: 2016-06-17 Yao Qi <yao.qi@linaro.org> * gdb.base/step-over-exit.c: New. * gdb.base/step-over-exit.exp: New.
2016-06-17 11:25:12 +02:00
static void unsuspend_all_lwps (struct lwp_info *except);
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
static void mark_lwp_dead (struct lwp_info *lwp, int wstat);
Linux gdbserver confused when event randomization picks process exit event The tail end of linux_wait_1 isn't expecting that the select_event_lwp machinery can pick a whole-process exit event to report to GDB. When that happens, both gdb and gdbserver end up quite confused: ... (gdb) [Thread 24971.24971] #1 stopped. 0x0000003615a011f0 in ?? () c& Continuing. (gdb) [New Thread 24971.24981] [New Thread 24983.24983] [New Thread 24971.24982] [Thread 24983.24983] #3 stopped. 0x0000003615ebc7cc in __libc_fork () at ../nptl/sysdeps/unix/sysv/linux/fork.c:130 130 pid = ARCH_FORK (); [New Thread 24984.24984] Error in re-setting breakpoint -16: PC register is not available Error in re-setting breakpoint -17: PC register is not available Error in re-setting breakpoint -18: PC register is not available Error in re-setting breakpoint -19: PC register is not available Error in re-setting breakpoint -24: PC register is not available Error in re-setting breakpoint -25: PC register is not available Error in re-setting breakpoint -26: PC register is not available Error in re-setting breakpoint -27: PC register is not available Error in re-setting breakpoint -28: PC register is not available Error in re-setting breakpoint -29: PC register is not available Error in re-setting breakpoint -30: PC register is not available PC register is not available (gdb) gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (add_lwp): Set waitstatus to TARGET_WAITKIND_IGNORE. (linux_thread_alive): Use lwp_is_marked_dead. (extended_event_reported): Delete. (linux_wait_1): Check if waitstatus is TARGET_WAITKIND_IGNORE instead of extended_event_reported. (mark_lwp_dead): Don't set the 'dead' flag. Store the waitstatus as well. (lwp_is_marked_dead): New function. (lwp_running): Use lwp_is_marked_dead. * linux-low.h: Delete 'dead' field, and update 'waitstatus's comment.
2015-08-06 11:30:17 +02:00
static int lwp_is_marked_dead (struct lwp_info *lwp);
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
static int kill_lwp (unsigned long lwpid, int signo);
gdbserver: Fix non-stop / fork / step-over issues Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html This adds a test that has a multithreaded program have several threads continuously fork, while another thread continuously steps over a breakpoint. This exposes several intertwined issues, which this patch addresses: - When we're stopping and suspending threads, some thread may fork, and we missed setting its suspend count to 1, like we do when a new clone/thread is detected. When we next unsuspend threads, the fork child's suspend count goes below 0, which is bogus and fails an assertion. - If a step-over is cancelled because a signal arrives, but then gdb is not interested in the signal, we pass the signal straight back to the inferior. However, we miss that we need to re-increment the suspend counts of all other threads that had been paused for the step-over. As a result, other threads indefinitely end up stuck stopped. - If a detach request comes in just while gdbserver is handling a step-over (in the test at hand, this is GDB detaching the fork child), gdbserver internal errors in stabilize_thread's helpers, which assert that all thread's suspend counts are 0 (otherwise we wouldn't be able to move threads out of the jump pads). The suspend counts aren't 0 while a step-over is in progress, because all threads but the one stepping past the breakpoint must remain paused until the step-over finishes and the breakpoint can be reinserted. - Occasionally, we see "BAD - reinserting but not stepping." being output (from within linux_resume_one_lwp_throw). That was because GDB pokes memory while gdbserver is busy with a step-over, and that suspends threads, and then re-resumes them with proceed_one_lwp, which missed another reason to tell linux_resume_one_lwp that the thread should be set back to stepping. - In a couple places, we were resuming threads that are meant to be suspended. E.g., when a vCont;c/s request for thread B comes in just while gdbserver is stepping thread A past a breakpoint. The resume for thread B must be deferred until the step-over finishes. - The test runs with both "set detach-on-fork" on and off. When off, it exercises the case of GDB detaching the fork child explicitly. When on, it exercises the case of gdb resuming the child explicitly. In the "off" case, gdb seems to exponentially become slower as new inferiors are created. This is _very_ noticeable as with only 100 inferiors gdb is crawling already, which makes the test take quite a bit to run. For that reason, I've disabled the "off" variant for now. gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * target/waitstatus.h (enum target_stop_reason) <TARGET_STOPPED_BY_SINGLE_STEP>: New value. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the fork child's suspend count if stopping and suspending threads. (check_stopped_by_breakpoint): If stopped by trace, set the LWP's stop reason to TARGET_STOPPED_BY_SINGLE_STEP. (linux_detach): Complete an ongoing step-over. (lwp_suspended_inc, lwp_suspended_decr): New functions. Use throughout. (resume_stopped_resumed_lwps): Don't resume a suspended thread. (linux_wait_1): If passing a signal to the inferior after finishing a step-over, unsuspend and re-resume all lwps. If we see a single-step event but the thread should be continuing, don't pass the trap to gdb. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use internal_error instead of gdb_assert. (enqueue_pending_signal): New function. (check_ptrace_stopped_lwp_gone): Add debug output. (start_step_over): Use internal_error instead of gdb_assert. (complete_ongoing_step_over): New function. (linux_resume_one_thread): Don't resume a suspended thread. (proceed_one_lwp): If the LWP is stepping over a breakpoint, reset it stepping. gdb/testsuite/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * gdb.threads/forking-threads-plus-breakpoint.exp: New file. * gdb.threads/forking-threads-plus-breakpoint.c: New file.
2015-08-06 11:30:18 +02:00
static void enqueue_pending_signal (struct lwp_info *lwp, int signal, siginfo_t *info);
static int linux_low_ptrace_options (int attached);
Fix failure to detach if process exits while detaching on Linux This commit fixes detaching on Linux when some thread exits the whole thread group (process) just while we're detaching. On Linux, a ptracer must detach from each LWP individually, with PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if one of the already-detached threads causes the whole thread group to exit (e.g., simply calls exit), the kernel force-kills the other threads in the group, making them zombie, just as we're still detaching them. Since PTRACE_DETACH against a zombie thread fails with ESRCH, and gdb/gdbserver are not expecting this, the detach fails with an error like: "Can't detach process: No such process.". This patch detects this detach failure as normal, and instead of erroring out, reaps the now-dead thread. New test included, that exercises several different scenarios that cause GDB/GDBserver to error out when it should not. Tested on x86-64 GNU/Linux with {unix, native-gdbserver, native-extended-gdbserver} Note: without the previous fix, the "single-process + continue" variant of the new test would fail with: (gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent continue Continuing. Warning: Could not insert hardware watchpoint 3. Could not insert hardware breakpoints: You may have requested too many hardware breakpoints/watchpoints. Command aborted. (gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue gdb/gdbserver/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * linux-low.c: Change interface to take the target lwp_info pointer directly and return void. Handle detaching from a zombie thread. (linux_detach_lwp_callback): New function. (linux_detach): Detach from the leader thread after detaching from the clone threads. gdb/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * inf-ptrace.c (inf_ptrace_detach_success): New function, factored out from ... (inf_ptrace_detach): ... here. * inf-ptrace.h (inf_ptrace_detach_success): New declaration. * linux-nat.c (get_pending_status): Rename to ... (get_detach_signal): ... this, and return a host signal instead of filling in a wait status. (detach_one_lwp): New function, factored out from detach_callback and adjusted to handle detaching from a zombie thread. (detach_callback): Skip the leader thread. (linux_nat_detach): No longer defer to inf_ptrace_detach to detach the leader thread, nor build a signal string to pass down. Instead, use target_announce_detach, detach_one_lwp and inf_ptrace_detach_success. gdb/testsuite/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * gdb.threads/process-dies-while-detaching.c: New file. * gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
static int check_ptrace_stopped_lwp_gone (struct lwp_info *lp);
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
/* When the event-loop is doing a step-over, this points at the thread
being stepped. */
ptid_t step_over_bkpt;
gdbserver/linux-low: turn 'get_pc' and 'set_pc' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_pc' and 'set_pc' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. * linux-low.cc (supports_breakpoints): Turn into... (linux_process_target::low_supports_breakpoints): ...this. (linux_process_target::low_get_pc): Define. (linux_process_target::low_set_pc): Define. Update the callers below. (linux_process_target::get_pc) (linux_process_target::save_stop_reason) (linux_process_target::maybe_move_out_of_jump_pad) (linux_process_target::wait_1) (linux_process_target::resume_one_lwp_throw) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (linux_process_target::read_pc) (linux_process_target::write_pc) * linux-x86-low.cc (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (x86_target::low_supports_breakpoints): Define. (x86_get_pc): Turn into... (x86_target::low_get_pc): ...this. (x86_set_pc): Turn into... (x86_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (arm_target::low_supports_breakpoints) (arm_target::low_get_pc) (arm_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (bfin_target::low_supports_breakpoints) (bfin_target::low_get_pc) (bfin_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (cris_target::low_supports_breakpoints) (cris_target::low_get_pc) (cris_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (crisv32_target::low_supports_breakpoints) (crisv32_target::low_get_pc) (crisv32_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m32r_target::low_supports_breakpoints) (m32r_target::low_get_pc) (m32r_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m68k_target::low_supports_breakpoints) (m68k_target::low_get_pc) (m68k_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (nios2_target::low_supports_breakpoints) (nios2_target::low_get_pc) (nios2_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (sh_target::low_supports_breakpoints) (sh_target::low_get_pc) (sh_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (xtensa_target::low_supports_breakpoints) (xtensa_target::low_get_pc) (xtensa_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_supports_breakpoints> <low_get_pc>: Declare. (sparc_target::low_supports_breakpoints) (sparc_target::low_get_pc): Define. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tile_target::low_supports_breakpoints) (tile_target::low_get_pc) (tile_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (aarch64_target::low_supports_breakpoints): Define. (aarch64_get_pc): Turn into... (aarch64_target::low_get_pc): ...this. (aarch64_set_pc): Turn into... (aarch64_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (mips_target::low_supports_breakpoints): Define. (mips_get_pc): Turn into... (mips_target::low_get_pc): ...this. (mips_set_pc): Turn into... (mips_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (ppc_target::low_supports_breakpoints): Define. (ppc_get_pc): Turn into... (ppc_target::low_get_pc): ...this. (ppc_set_pc): Turn into... (ppc_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (riscv_target::low_supports_breakpoints): Define. (riscv_get_pc): Turn into... (riscv_target::low_get_pc): ...this. (riscv_set_pc): Turn into... (riscv_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (s390_target::low_supports_breakpoints): Define. (s390_get_pc): Turn into... (s390_target::low_get_pc): ...this. (s390_set_pc): Turn into... (s390_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tic6x_target::low_supports_breakpoints): Define. (tic6x_get_pc): Turn into... (tic6x_target::low_get_pc): ...this. (tic6x_set_pc): Turn into... (tic6x_target::low_set_pc): ...this. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
bool
linux_process_target::low_supports_breakpoints ()
{
return false;
}
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
gdbserver/linux-low: turn 'get_pc' and 'set_pc' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_pc' and 'set_pc' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. * linux-low.cc (supports_breakpoints): Turn into... (linux_process_target::low_supports_breakpoints): ...this. (linux_process_target::low_get_pc): Define. (linux_process_target::low_set_pc): Define. Update the callers below. (linux_process_target::get_pc) (linux_process_target::save_stop_reason) (linux_process_target::maybe_move_out_of_jump_pad) (linux_process_target::wait_1) (linux_process_target::resume_one_lwp_throw) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (linux_process_target::read_pc) (linux_process_target::write_pc) * linux-x86-low.cc (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (x86_target::low_supports_breakpoints): Define. (x86_get_pc): Turn into... (x86_target::low_get_pc): ...this. (x86_set_pc): Turn into... (x86_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (arm_target::low_supports_breakpoints) (arm_target::low_get_pc) (arm_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (bfin_target::low_supports_breakpoints) (bfin_target::low_get_pc) (bfin_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (cris_target::low_supports_breakpoints) (cris_target::low_get_pc) (cris_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (crisv32_target::low_supports_breakpoints) (crisv32_target::low_get_pc) (crisv32_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m32r_target::low_supports_breakpoints) (m32r_target::low_get_pc) (m32r_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m68k_target::low_supports_breakpoints) (m68k_target::low_get_pc) (m68k_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (nios2_target::low_supports_breakpoints) (nios2_target::low_get_pc) (nios2_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (sh_target::low_supports_breakpoints) (sh_target::low_get_pc) (sh_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (xtensa_target::low_supports_breakpoints) (xtensa_target::low_get_pc) (xtensa_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_supports_breakpoints> <low_get_pc>: Declare. (sparc_target::low_supports_breakpoints) (sparc_target::low_get_pc): Define. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tile_target::low_supports_breakpoints) (tile_target::low_get_pc) (tile_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (aarch64_target::low_supports_breakpoints): Define. (aarch64_get_pc): Turn into... (aarch64_target::low_get_pc): ...this. (aarch64_set_pc): Turn into... (aarch64_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (mips_target::low_supports_breakpoints): Define. (mips_get_pc): Turn into... (mips_target::low_get_pc): ...this. (mips_set_pc): Turn into... (mips_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (ppc_target::low_supports_breakpoints): Define. (ppc_get_pc): Turn into... (ppc_target::low_get_pc): ...this. (ppc_set_pc): Turn into... (ppc_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (riscv_target::low_supports_breakpoints): Define. (riscv_get_pc): Turn into... (riscv_target::low_get_pc): ...this. (riscv_set_pc): Turn into... (riscv_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (s390_target::low_supports_breakpoints): Define. (s390_get_pc): Turn into... (s390_target::low_get_pc): ...this. (s390_set_pc): Turn into... (s390_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tic6x_target::low_supports_breakpoints): Define. (tic6x_get_pc): Turn into... (tic6x_target::low_get_pc): ...this. (tic6x_set_pc): Turn into... (tic6x_target::low_set_pc): ...this. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
CORE_ADDR
linux_process_target::low_get_pc (regcache *regcache)
{
return 0;
}
void
linux_process_target::low_set_pc (regcache *regcache, CORE_ADDR newpc)
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
{
gdbserver/linux-low: turn 'get_pc' and 'set_pc' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_pc' and 'set_pc' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. * linux-low.cc (supports_breakpoints): Turn into... (linux_process_target::low_supports_breakpoints): ...this. (linux_process_target::low_get_pc): Define. (linux_process_target::low_set_pc): Define. Update the callers below. (linux_process_target::get_pc) (linux_process_target::save_stop_reason) (linux_process_target::maybe_move_out_of_jump_pad) (linux_process_target::wait_1) (linux_process_target::resume_one_lwp_throw) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (linux_process_target::read_pc) (linux_process_target::write_pc) * linux-x86-low.cc (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (x86_target::low_supports_breakpoints): Define. (x86_get_pc): Turn into... (x86_target::low_get_pc): ...this. (x86_set_pc): Turn into... (x86_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (arm_target::low_supports_breakpoints) (arm_target::low_get_pc) (arm_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (bfin_target::low_supports_breakpoints) (bfin_target::low_get_pc) (bfin_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (cris_target::low_supports_breakpoints) (cris_target::low_get_pc) (cris_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (crisv32_target::low_supports_breakpoints) (crisv32_target::low_get_pc) (crisv32_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m32r_target::low_supports_breakpoints) (m32r_target::low_get_pc) (m32r_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m68k_target::low_supports_breakpoints) (m68k_target::low_get_pc) (m68k_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (nios2_target::low_supports_breakpoints) (nios2_target::low_get_pc) (nios2_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (sh_target::low_supports_breakpoints) (sh_target::low_get_pc) (sh_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (xtensa_target::low_supports_breakpoints) (xtensa_target::low_get_pc) (xtensa_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_supports_breakpoints> <low_get_pc>: Declare. (sparc_target::low_supports_breakpoints) (sparc_target::low_get_pc): Define. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tile_target::low_supports_breakpoints) (tile_target::low_get_pc) (tile_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (aarch64_target::low_supports_breakpoints): Define. (aarch64_get_pc): Turn into... (aarch64_target::low_get_pc): ...this. (aarch64_set_pc): Turn into... (aarch64_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (mips_target::low_supports_breakpoints): Define. (mips_get_pc): Turn into... (mips_target::low_get_pc): ...this. (mips_set_pc): Turn into... (mips_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (ppc_target::low_supports_breakpoints): Define. (ppc_get_pc): Turn into... (ppc_target::low_get_pc): ...this. (ppc_set_pc): Turn into... (ppc_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (riscv_target::low_supports_breakpoints): Define. (riscv_get_pc): Turn into... (riscv_target::low_get_pc): ...this. (riscv_set_pc): Turn into... (riscv_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (s390_target::low_supports_breakpoints): Define. (s390_get_pc): Turn into... (s390_target::low_get_pc): ...this. (s390_set_pc): Turn into... (s390_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tic6x_target::low_supports_breakpoints): Define. (tic6x_get_pc): Turn into... (tic6x_target::low_get_pc): ...this. (tic6x_set_pc): Turn into... (tic6x_target::low_set_pc): ...this. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
gdb_assert_not_reached ("linux target op low_set_pc is not implemented");
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
}
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
gdbserver/linux-low: turn 'supports_software_single_step' and 'get_next_pcs' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Remove the 'supports_software_single_step' linux target op and let the concrete linux target define it by overriding the op in process_stratum_target. Turn the 'get_next_pcs' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <supports_software_single_step>: Remove. <low_get_next_pcs>: Declare. * linux-low.cc (can_software_single_step): Remove. (linux_process_target::low_get_next_pcs): Define. (linux_process_target::supports_software_single_step): Remove. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::wait_1) (linux_process_target::install_software_single_step_breakpoints) (linux_process_target::single_step) (linux_process_target::thread_needs_step_over) (linux_process_target::proceed_one_lwp) (linux_process_target::supports_range_stepping) * linux-x86-low.cc (the_low_target): Remove the op field. * linux-aarch64-low.cc (the_low_target): Ditto. * linux-bfin-low.cc (the_low_target): Ditto. * linux-cris-low.cc (the_low_target): Ditto. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-mips-low.cc (the_low_target): Ditto. * linux-nios2-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-riscv-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-sparc-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto. * linux-arm-low.cc (class arm_target) <low_get_next_pcs> <supports_software_single_step>: Declare. (arm_target::supports_software_single_step): Define. (arm_gdbserver_get_next_pcs): Turn into... (arm_target::low_get_next_pcs): ...this. (the_low_target): Remove the op field.
2020-04-02 15:11:26 +02:00
std::vector<CORE_ADDR>
linux_process_target::low_get_next_pcs (regcache *regcache)
{
gdb_assert_not_reached ("linux target op low_get_next_pcs is not "
"implemented");
}
gdbserver/linux-low: turn the 'decr_pc_after_break' field into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'decr_pc_after_break' linux_target_ops field into a method of linux_process_target. * linux-low.h (struct linux_target_ops) <decr_pc_after_break>: Remove. (class linux_process_target) <low_decr_pc_after_break>: New method declaration. * linux-low.cc (linux_process_target::low_decr_pc_after_break): New method implementation. Update the users below. (linux_process_target::save_stop_reason) (linux_process_target::wait_1) * linux-x86-low.cc (class x86_target) <low_decr_pc_after_break>: New declaration. (x86_target::low_decr_pc_after_break): New method implementation. (the_low_target): Remove the field. * linux-bfin-low.cc (class bfin_target) <low_decr_pc_after_break>: New declaration. (bfin_target::low_decr_pc_after_break): New method implementation. (the_low_target): Remove the field. * linux-m68k-low.cc (class m68k_target) <low_decr_pc_after_break>: New declaration. (m68k_target::low_decr_pc_after_break): New method implementation. (the_low_target): Remove the field. * linux-s390-low.cc (class s390_target) <low_decr_pc_after_break>: New declaration. (s390_target::low_decr_pc_after_break): New method implementation. (the_low_target): Remove the field. * linux-aarch64-low.cc (the_low_target): Remove the field. * linux-arm-low.cc (the_low_target): Remove the field. * linux-cris-low.cc (the_low_target): Remove the field. * linux-crisv32-low.cc (the_low_target): Remove the field. * linux-m32r-low.cc (the_low_target): Remove the field. * linux-mips-low.cc (the_low_target): Remove the field. * linux-nios2-low.cc (the_low_target): Remove the field. * linux-ppc-low.cc (the_low_target): Remove the field. * linux-riscv-low.cc (the_low_target): Remove the field. * linux-sh-low.cc (the_low_target): Remove the field. * linux-sparc-low.cc (the_low_target): Remove the field. * linux-tic6x-low.cc (the_low_target): Remove the field. * linux-tile-low.cc (the_low_target): Remove the field. * linux-xtensa-low.cc (the_low_target): Remove the field.
2020-04-02 15:11:26 +02:00
int
linux_process_target::low_decr_pc_after_break ()
{
return 0;
}
range stepping: gdbserver (x86 GNU/Linux) This patch adds support for range stepping to GDBserver, teaching it about vCont;r. It'd be easy to enable this for all hardware single-step targets without needing the linux_target_ops hook, however, at least PPC needs special care, due to the fact that PPC atomic sequences can't be hardware single-stepped through, a thing which GDBserver doesn't know about. So this leaves the support limited to x86/x86_64. gdb/ 2013-05-23 Pedro Alves <palves@redhat.com> * NEWS: Mention GDBserver range stepping support. gdb/gdbserver/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * linux-low.c (lwp_in_step_range): New function. (linux_wait_1): If the thread was range stepping and stopped outside the stepping range, report the stop to GDB. Otherwise, continue stepping. Add range stepping debug output. (linux_set_resume_request): Copy the step range from the resume request to the lwp. (linux_supports_range_stepping): New. (linux_target_ops) <supports_range_stepping>: Set to linux_supports_range_stepping. * linux-low.h (struct linux_target_ops) <supports_range_stepping>: New field. (struct lwp_info) <step_range_start, step_range_end>: New fields. * linux-x86-low.c (x86_supports_range_stepping): New. (the_low_target) <supports_range_stepping>: Set to x86_supports_range_stepping. * server.c (handle_v_cont): Handle 'r' action. (handle_v_requests): Append ";r" if the target supports range stepping. * target.h (struct thread_resume) <step_range_start, step_range_end>: New fields. (struct target_ops) <supports_range_stepping>: New field. (target_supports_range_stepping): New macro.
2013-05-23 19:17:50 +02:00
/* True if LWP is stopped in its stepping range. */
static int
lwp_in_step_range (struct lwp_info *lwp)
{
CORE_ADDR pc = lwp->stop_pc;
return (pc >= lwp->step_range_start && pc < lwp->step_range_end);
}
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
/* The read/write ends of the pipe registered as waitable file in the
event loop. */
static int linux_event_pipe[2] = { -1, -1 };
/* True if we're currently in async mode. */
#define target_is_async_p() (linux_event_pipe[0] != -1)
static void send_sigstop (struct lwp_info *lwp);
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
/* Return non-zero if HEADER is a 64-bit ELF file. */
static int
elf_64_header_p (const Elf64_Ehdr *header, unsigned int *machine)
{
if (header->e_ident[EI_MAG0] == ELFMAG0
&& header->e_ident[EI_MAG1] == ELFMAG1
&& header->e_ident[EI_MAG2] == ELFMAG2
&& header->e_ident[EI_MAG3] == ELFMAG3)
{
*machine = header->e_machine;
return header->e_ident[EI_CLASS] == ELFCLASS64;
}
*machine = EM_NONE;
return -1;
}
/* Return non-zero if FILE is a 64-bit ELF file,
zero if the file is not a 64-bit ELF file,
and -1 if the file is not accessible or doesn't exist. */
static int
elf_64_file_p (const char *file, unsigned int *machine)
{
Elf64_Ehdr header;
int fd;
fd = open (file, O_RDONLY);
if (fd < 0)
return -1;
if (read (fd, &header, sizeof (header)) != sizeof (header))
{
close (fd);
return 0;
}
close (fd);
return elf_64_header_p (&header, machine);
}
/* Accepts an integer PID; Returns true if the executable PID is
running is a 64-bit ELF file.. */
int
linux_pid_exe_is_elf_64_file (int pid, unsigned int *machine)
{
Normalize on PATH_MAX instead of MAXPATHLEN throughout. With the pathmax gnulib module in place, we can use PATH_MAX consistently throughout, instead of the current mixbag of PATH_MAX and MAXPATHLEN uses. It's no longer necessary to include sys/param.h (supposedly, I can't check all ports touched here) for MAXPATHLEN. Don't remove sys/param.h from GDB's configure.ac, as later tests in the file use HAVE_SYS_PARAM_H checks. Tested on x86_64 Fedora 17. Also cross-built for --host=i686-w64-mingw32, and --host=i586-pc-msdosdjgpp. gdb/ 2013-07-01 Pedro Alves <palves@redhat.com> * defs.h: Include "pathmax.h". * utils.c: Don't include sys/param.h. (gdb_realpath): Remove code that checks for MAXPATHLEN. * solib-ia64-hpux.c (ia64_hpux_handle_load_event): Use PATH_MAX instead of MAXPATHLEN. * solib-sunos.c: Don't include sys/param.h. * xcoffread.c: Don't include sys/param.h. * bsd-kvm.c: Don't include sys/param.h. * darwin-nat.c: Don't include sys/param.h. (darwin_pid_to_exec_file): Use PATH_MAX instead of MAXPATHLEN. * darwin-nat-info.c: Don't include sys/param.h. * fbsd-nat.c (fbsd_pid_to_exec_file): Use PATH_MAX instead of MAXPATHLEN. * i386obsd-nat.c: Don't include sys/param.h. * inf-child.c: Don't include sys/param.h. (inf_child_fileio_readlink): Use PATH_MAX instead of MAXPATHLEN. * linux-fork.c: Don't include sys/param.h. (fork_save_infrun_state): Use PATH_MAX instead of MAXPATHLEN. * linux-nat.c: Don't include sys/param.h. (linux_child_pid_to_exec_file, linux_proc_pending_signals) (linux_proc_pending_signals): Use PATH_MAX instead of MAXPATHLEN. * m68klinux-nat.c: Don't include sys/param.h. * nbsd-nat.c: Don't include sys/param.h. (nbsd_pid_to_exec_file): Use PATH_MAX instead of MAXPATHLEN. * ppc-linux-nat.c: Don't include sys/param.h. * rs6000-nat.c: Don't include sys/param.h. * spu-linux-nat.c. Don't include sys/param.h. * windows-nat.c: Don't include sys/param.h. * xtensa-linux-nat.c: Don't include sys/param.h. * config/i386/nm-fbsd.h: Don't include sys/param.h. gdb/gdbserver/ 2013-07-01 Pedro Alves <palves@redhat.com> * server.h: Include "pathmax.h". * linux-low.c: Don't include sys/param.h. (linux_pid_exe_is_elf_64_file): Use PATH_MAX instead of MAXPATHLEN. * win32-low.c: Don't include sys/param.h. (win32_create_inferior): Use PATH_MAX instead of MAXPATHLEN.
2013-07-01 13:28:30 +02:00
char file[PATH_MAX];
sprintf (file, "/proc/%d/exe", pid);
return elf_64_file_p (file, machine);
}
gdbserver/linux-low: turn process/thread addition/deletion ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'new_process', 'delete_process', 'new_thread', 'delete_thread', and 'new_fork' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <add_linux_process> <add_lwp> <delete_lwp> <attach_lwp> <detach_one_lwp> <check_zombie_leaders> <filter_exit_event> <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. * linux-low.cc (delete_lwp): Turn into... (linux_process_target::delete_lwp): ...this. (linux_process_target::low_delete_thread): Define. (linux_add_process): Turn into... (linux_process_target::add_linux_process): ...this. (linux_process_target::low_new_process): Define. (linux_process_target::low_delete_process): Define. (linux_process_target::low_new_fork): Define. (add_lwp): Turn into... (linux_process_target::add_lwp): ...this. (linux_process_target::low_new_thread): Define. (linux_attach_lwp): Turn into... (linux_process_target::attach_lwp): ...this. (linux_detach_one_lwp): Turn into... (linux_process_target::detach_one_lwp): ...this. (linux_detach_lwp_callback): Remove and inline... (linux_process_target::detach): ...here. (check_zombie_leaders): Turn into... (linux_process_target::check_zombie_leaders): ...this. (filter_exit_event): Turn into... (linux_process_target::filter_exit_event): ...this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::create_inferior) (attach_proc_task_lwp_callback) (linux_process_target::attach) (linux_process_target::detach) (linux_process_target::mourn) * thread-db.cc (attach_thread) * linux-x86-low.cc (class x86_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (x86_linux_new_process): Turn into... (x86_target::low_new_process): ...this. (x86_linux_delete_process): Turn into... (x86_target::low_delete_process): ...this. (x86_target::low_new_thread): Define. (x86_target::low_delete_thread): Define. (x86_linux_new_fork): Turn into... (x86_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (aarch64_linux_new_process): Turn into... (aarch64_target::low_new_process): ...this. (aarch64_linux_delete_process): Turn into... (aarch64_target::low_delete_process): ...this. (aarch64_target::low_new_thread): Define. (aarch64_target::low_delete_thread): Define. (aarch64_linux_new_fork): Turn into... (aarch64_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (arm_new_process): Turn into... (arm_target::low_new_process): ...this. (arm_delete_process): Turn into... (arm_target::low_delete_process): ...this. (arm_new_thread): Turn into... (arm_target::low_new_thread): ...this. (arm_delete_thread): Turn into... (arm_target::low_delete_thread): ...this. (arm_new_fork): Turn into... (arm_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (mips_linux_new_process): Turn into... (mips_target::low_new_process): ...this. (mips_linux_delete_process): Turn into... (mips_target::low_delete_process): ...this. (mips_linux_new_thread): Turn into... (mips_target::low_new_thread): ...this. (mips_linux_delete_thread): Turn into... (mips_target::low_delete_thread): ...this. (mips_linux_new_fork): Turn into... (mips_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:28 +02:00
void
linux_process_target::delete_lwp (lwp_info *lwp)
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
{
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
struct thread_info *thr = get_lwp_thread (lwp);
if (debug_threads)
debug_printf ("deleting %ld\n", lwpid_of (thr));
remove_thread (thr);
lwp_info: Make the arch code free arch_lwp_info I have the goal of "poisoning" the XNEW/xfree-family of functions, so that we catch their usages with non-POD types. A few things need to be fixed in the mean time, this is one. The common lwp code in linux-nat.c and gdbserver/linux-low.c xfrees the private lwp data of type arch_lwp_info. However, that type is opaque from its point of view, as its defined differently in each arch-specific implementation. This trips on the std::is_pod<T> check, since the compiler can't tell whether the type is POD or not if it doesn't know about it. My initial patch [1] made a class hierarchy with a virtual destructor. However, as Pedro pointed out, we only have one native architecture at the time built in gdb and gdbserver, so that's overkill. Instead, we can move the responsibility of free'ing arch_lwp_info to the arch code (which is also the one that allocated it in the first place). This is what this patch does. Also, I had the concern that if we wanted to use C++ features in these structures, we would have a problem with the one-definition rule. However, since a build will only have one version of arch_lwp_info, that's not a problem. There are changes in arch-specific files, I was only able to built-test this patch with the following cross-compilers: aarch64-linux-gnu alpha-linux-gnu arm-linux-gnueabihf hppa-linux-gnu m68k-linux-gnu mips64el-linux-gnuabi64 powerpc64-linux-gnu s390x-linux-gnu sh4-linux-gnu sparc64-linux-gnu x86_64-linux-gnu x86_64-w64-mingw32 A buildbot run didn't find any regression. [1] https://sourceware.org/ml/gdb-patches/2017-08/msg00255.html gdb/ChangeLog: * linux-nat.h (linux_nat_set_delete_thread): New declaration. * linux-nat.c (linux_nat_delete_thread): New variable. (lwp_free): Invoke linux_nat_delete_thread if set. (linux_nat_set_delete_thread): New function. * aarch64-linux-nat.c (_initialize_aarch64_linux_nat): Assign thread delete callback. * arm-linux-nat.c (arm_linux_delete_thread): New function. (_initialize_arm_linux_nat): Assign thread delete callback. * s390-linux-nat.c (s390_delete_thread): New function. (_initialize_s390_nat): Assign thread delete callback. * x86-linux-nat.c (x86_linux_add_target): Likewise. * nat/aarch64-linux.c (aarch64_linux_delete_thread): New function. * nat/aarch64-linux.h (aarch64_linux_delete_thread): New declaration. * nat/x86-linux.c (x86_linux_delete_thread): New function. * nat/x86-linux.h (x86_linux_delete_thread): New declaration. gdb/gdbserver/ChangeLog: * linux-aarch64-low.c (the_low_target): Add thread delete callback. * linux-arm-low.c (arm_delete_thread): New function. (the_low_target): Add thread delete callback. * linux-bfin-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-low.c (delete_lwp): Invoke delete_thread callback if set. * linux-low.h (struct linux_target_ops) <delete_thread>: New field. * linux-m32r-low.c (the_low_target): Add thread delete callback. * linux-mips-low.c (mips_linux_delete_thread): New function. (the_low_target): Add thread delete callback. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-tile-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise.
2017-10-12 22:48:22 +02:00
gdbserver/linux-low: turn process/thread addition/deletion ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'new_process', 'delete_process', 'new_thread', 'delete_thread', and 'new_fork' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <add_linux_process> <add_lwp> <delete_lwp> <attach_lwp> <detach_one_lwp> <check_zombie_leaders> <filter_exit_event> <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. * linux-low.cc (delete_lwp): Turn into... (linux_process_target::delete_lwp): ...this. (linux_process_target::low_delete_thread): Define. (linux_add_process): Turn into... (linux_process_target::add_linux_process): ...this. (linux_process_target::low_new_process): Define. (linux_process_target::low_delete_process): Define. (linux_process_target::low_new_fork): Define. (add_lwp): Turn into... (linux_process_target::add_lwp): ...this. (linux_process_target::low_new_thread): Define. (linux_attach_lwp): Turn into... (linux_process_target::attach_lwp): ...this. (linux_detach_one_lwp): Turn into... (linux_process_target::detach_one_lwp): ...this. (linux_detach_lwp_callback): Remove and inline... (linux_process_target::detach): ...here. (check_zombie_leaders): Turn into... (linux_process_target::check_zombie_leaders): ...this. (filter_exit_event): Turn into... (linux_process_target::filter_exit_event): ...this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::create_inferior) (attach_proc_task_lwp_callback) (linux_process_target::attach) (linux_process_target::detach) (linux_process_target::mourn) * thread-db.cc (attach_thread) * linux-x86-low.cc (class x86_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (x86_linux_new_process): Turn into... (x86_target::low_new_process): ...this. (x86_linux_delete_process): Turn into... (x86_target::low_delete_process): ...this. (x86_target::low_new_thread): Define. (x86_target::low_delete_thread): Define. (x86_linux_new_fork): Turn into... (x86_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (aarch64_linux_new_process): Turn into... (aarch64_target::low_new_process): ...this. (aarch64_linux_delete_process): Turn into... (aarch64_target::low_delete_process): ...this. (aarch64_target::low_new_thread): Define. (aarch64_target::low_delete_thread): Define. (aarch64_linux_new_fork): Turn into... (aarch64_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (arm_new_process): Turn into... (arm_target::low_new_process): ...this. (arm_delete_process): Turn into... (arm_target::low_delete_process): ...this. (arm_new_thread): Turn into... (arm_target::low_new_thread): ...this. (arm_delete_thread): Turn into... (arm_target::low_delete_thread): ...this. (arm_new_fork): Turn into... (arm_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (mips_linux_new_process): Turn into... (mips_target::low_new_process): ...this. (mips_linux_delete_process): Turn into... (mips_target::low_delete_process): ...this. (mips_linux_new_thread): Turn into... (mips_target::low_new_thread): ...this. (mips_linux_delete_thread): Turn into... (mips_target::low_delete_thread): ...this. (mips_linux_new_fork): Turn into... (mips_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:28 +02:00
low_delete_thread (lwp->arch_private);
lwp_info: Make the arch code free arch_lwp_info I have the goal of "poisoning" the XNEW/xfree-family of functions, so that we catch their usages with non-POD types. A few things need to be fixed in the mean time, this is one. The common lwp code in linux-nat.c and gdbserver/linux-low.c xfrees the private lwp data of type arch_lwp_info. However, that type is opaque from its point of view, as its defined differently in each arch-specific implementation. This trips on the std::is_pod<T> check, since the compiler can't tell whether the type is POD or not if it doesn't know about it. My initial patch [1] made a class hierarchy with a virtual destructor. However, as Pedro pointed out, we only have one native architecture at the time built in gdb and gdbserver, so that's overkill. Instead, we can move the responsibility of free'ing arch_lwp_info to the arch code (which is also the one that allocated it in the first place). This is what this patch does. Also, I had the concern that if we wanted to use C++ features in these structures, we would have a problem with the one-definition rule. However, since a build will only have one version of arch_lwp_info, that's not a problem. There are changes in arch-specific files, I was only able to built-test this patch with the following cross-compilers: aarch64-linux-gnu alpha-linux-gnu arm-linux-gnueabihf hppa-linux-gnu m68k-linux-gnu mips64el-linux-gnuabi64 powerpc64-linux-gnu s390x-linux-gnu sh4-linux-gnu sparc64-linux-gnu x86_64-linux-gnu x86_64-w64-mingw32 A buildbot run didn't find any regression. [1] https://sourceware.org/ml/gdb-patches/2017-08/msg00255.html gdb/ChangeLog: * linux-nat.h (linux_nat_set_delete_thread): New declaration. * linux-nat.c (linux_nat_delete_thread): New variable. (lwp_free): Invoke linux_nat_delete_thread if set. (linux_nat_set_delete_thread): New function. * aarch64-linux-nat.c (_initialize_aarch64_linux_nat): Assign thread delete callback. * arm-linux-nat.c (arm_linux_delete_thread): New function. (_initialize_arm_linux_nat): Assign thread delete callback. * s390-linux-nat.c (s390_delete_thread): New function. (_initialize_s390_nat): Assign thread delete callback. * x86-linux-nat.c (x86_linux_add_target): Likewise. * nat/aarch64-linux.c (aarch64_linux_delete_thread): New function. * nat/aarch64-linux.h (aarch64_linux_delete_thread): New declaration. * nat/x86-linux.c (x86_linux_delete_thread): New function. * nat/x86-linux.h (x86_linux_delete_thread): New declaration. gdb/gdbserver/ChangeLog: * linux-aarch64-low.c (the_low_target): Add thread delete callback. * linux-arm-low.c (arm_delete_thread): New function. (the_low_target): Add thread delete callback. * linux-bfin-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-low.c (delete_lwp): Invoke delete_thread callback if set. * linux-low.h (struct linux_target_ops) <delete_thread>: New field. * linux-m32r-low.c (the_low_target): Add thread delete callback. * linux-mips-low.c (mips_linux_delete_thread): New function. (the_low_target): Add thread delete callback. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-tile-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise.
2017-10-12 22:48:22 +02:00
gdbserver/linux-low: use std::list to store pending signals Use std::list to store pending signals instead of a manually-managed linked list. This is a refactoring. In the existing code, pending signals are kept in a manually-created linked list with "prev" pointers. A new pending signal is thus inserted to the beginning of the list. When consuming, GDB goes until the end of the list, following the "prev" pointers, and processes the final item. With this patch, a new item is added to the end of the list and the item at the front of the list is consumed. In other words, the list elements used to be stored in reverse order; with this patch, they are stored in their order of arrival. This causes a change in the debug messages that print the pending signals. Otherwise, no behavioral change is expected. gdbserver/ChangeLog: 2020-06-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Use std::list to stop pending signal instead of manually-created linked list. * linux-low.h: Include <list>. (struct pending_signal): Move here from linux-low.cc. (struct lwp_info) <pending_signals> <pending_signals_to_report>: Update the type. * linux-low.cc (struct pending_signals): Remove. (linux_process_target::delete_lwp) (linux_process_target::add_lwp) (enqueue_one_deferred_signal) (dequeue_one_deferred_signal) (enqueue_pending_signal) (linux_process_target::resume_one_lwp_throw) (linux_process_target::thread_needs_step_over) (linux_process_target::resume_one_thread) (linux_process_target::proceed_one_lwp): Update the use of pending signal list.
2020-06-22 14:13:48 +02:00
delete lwp;
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
}
gdbserver/linux-low: turn process/thread addition/deletion ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'new_process', 'delete_process', 'new_thread', 'delete_thread', and 'new_fork' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <add_linux_process> <add_lwp> <delete_lwp> <attach_lwp> <detach_one_lwp> <check_zombie_leaders> <filter_exit_event> <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. * linux-low.cc (delete_lwp): Turn into... (linux_process_target::delete_lwp): ...this. (linux_process_target::low_delete_thread): Define. (linux_add_process): Turn into... (linux_process_target::add_linux_process): ...this. (linux_process_target::low_new_process): Define. (linux_process_target::low_delete_process): Define. (linux_process_target::low_new_fork): Define. (add_lwp): Turn into... (linux_process_target::add_lwp): ...this. (linux_process_target::low_new_thread): Define. (linux_attach_lwp): Turn into... (linux_process_target::attach_lwp): ...this. (linux_detach_one_lwp): Turn into... (linux_process_target::detach_one_lwp): ...this. (linux_detach_lwp_callback): Remove and inline... (linux_process_target::detach): ...here. (check_zombie_leaders): Turn into... (linux_process_target::check_zombie_leaders): ...this. (filter_exit_event): Turn into... (linux_process_target::filter_exit_event): ...this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::create_inferior) (attach_proc_task_lwp_callback) (linux_process_target::attach) (linux_process_target::detach) (linux_process_target::mourn) * thread-db.cc (attach_thread) * linux-x86-low.cc (class x86_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (x86_linux_new_process): Turn into... (x86_target::low_new_process): ...this. (x86_linux_delete_process): Turn into... (x86_target::low_delete_process): ...this. (x86_target::low_new_thread): Define. (x86_target::low_delete_thread): Define. (x86_linux_new_fork): Turn into... (x86_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (aarch64_linux_new_process): Turn into... (aarch64_target::low_new_process): ...this. (aarch64_linux_delete_process): Turn into... (aarch64_target::low_delete_process): ...this. (aarch64_target::low_new_thread): Define. (aarch64_target::low_delete_thread): Define. (aarch64_linux_new_fork): Turn into... (aarch64_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (arm_new_process): Turn into... (arm_target::low_new_process): ...this. (arm_delete_process): Turn into... (arm_target::low_delete_process): ...this. (arm_new_thread): Turn into... (arm_target::low_new_thread): ...this. (arm_delete_thread): Turn into... (arm_target::low_delete_thread): ...this. (arm_new_fork): Turn into... (arm_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (mips_linux_new_process): Turn into... (mips_target::low_new_process): ...this. (mips_linux_delete_process): Turn into... (mips_target::low_delete_process): ...this. (mips_linux_new_thread): Turn into... (mips_target::low_new_thread): ...this. (mips_linux_delete_thread): Turn into... (mips_target::low_delete_thread): ...this. (mips_linux_new_fork): Turn into... (mips_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:28 +02:00
void
linux_process_target::low_delete_thread (arch_lwp_info *info)
{
/* Default implementation should be overridden if architecture-specific
info is being used. */
gdb_assert (info == nullptr);
}
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
gdbserver/linux-low: turn process/thread addition/deletion ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'new_process', 'delete_process', 'new_thread', 'delete_thread', and 'new_fork' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <add_linux_process> <add_lwp> <delete_lwp> <attach_lwp> <detach_one_lwp> <check_zombie_leaders> <filter_exit_event> <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. * linux-low.cc (delete_lwp): Turn into... (linux_process_target::delete_lwp): ...this. (linux_process_target::low_delete_thread): Define. (linux_add_process): Turn into... (linux_process_target::add_linux_process): ...this. (linux_process_target::low_new_process): Define. (linux_process_target::low_delete_process): Define. (linux_process_target::low_new_fork): Define. (add_lwp): Turn into... (linux_process_target::add_lwp): ...this. (linux_process_target::low_new_thread): Define. (linux_attach_lwp): Turn into... (linux_process_target::attach_lwp): ...this. (linux_detach_one_lwp): Turn into... (linux_process_target::detach_one_lwp): ...this. (linux_detach_lwp_callback): Remove and inline... (linux_process_target::detach): ...here. (check_zombie_leaders): Turn into... (linux_process_target::check_zombie_leaders): ...this. (filter_exit_event): Turn into... (linux_process_target::filter_exit_event): ...this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::create_inferior) (attach_proc_task_lwp_callback) (linux_process_target::attach) (linux_process_target::detach) (linux_process_target::mourn) * thread-db.cc (attach_thread) * linux-x86-low.cc (class x86_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (x86_linux_new_process): Turn into... (x86_target::low_new_process): ...this. (x86_linux_delete_process): Turn into... (x86_target::low_delete_process): ...this. (x86_target::low_new_thread): Define. (x86_target::low_delete_thread): Define. (x86_linux_new_fork): Turn into... (x86_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (aarch64_linux_new_process): Turn into... (aarch64_target::low_new_process): ...this. (aarch64_linux_delete_process): Turn into... (aarch64_target::low_delete_process): ...this. (aarch64_target::low_new_thread): Define. (aarch64_target::low_delete_thread): Define. (aarch64_linux_new_fork): Turn into... (aarch64_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (arm_new_process): Turn into... (arm_target::low_new_process): ...this. (arm_delete_process): Turn into... (arm_target::low_delete_process): ...this. (arm_new_thread): Turn into... (arm_target::low_new_thread): ...this. (arm_delete_thread): Turn into... (arm_target::low_delete_thread): ...this. (arm_new_fork): Turn into... (arm_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (mips_linux_new_process): Turn into... (mips_target::low_new_process): ...this. (mips_linux_delete_process): Turn into... (mips_target::low_delete_process): ...this. (mips_linux_new_thread): Turn into... (mips_target::low_new_thread): ...this. (mips_linux_delete_thread): Turn into... (mips_target::low_delete_thread): ...this. (mips_linux_new_fork): Turn into... (mips_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:28 +02:00
process_info *
linux_process_target::add_linux_process (int pid, int attached)
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
{
struct process_info *proc;
proc = add_process (pid, attached);
Replace some xmalloc-family functions with XNEW-family ones This patch is part of the make-gdb-buildable-in-C++ effort. The idea is to change some calls to the xmalloc family of functions to calls to the equivalents in the XNEW family. This avoids adding an explicit cast, so it keeps the code a bit more readable. Some of them also map relatively well to a C++ equivalent (XNEW (struct foo) -> new foo), so it will be possible to do scripted replacements if needed. I only changed calls that were obviously allocating memory for one or multiple "objects". Allocation of variable sizes (such as strings or buffer handling) will be for later (and won't use XNEW). - xmalloc (sizeof (struct foo)) -> XNEW (struct foo) - xmalloc (num * sizeof (struct foo)) -> XNEWVEC (struct foo, num) - xcalloc (1, sizeof (struct foo)) -> XCNEW (struct foo) - xcalloc (num, sizeof (struct foo)) -> XCNEWVEC (struct foo, num) - xrealloc (p, num * sizeof (struct foo) -> XRESIZEVEC (struct foo, p, num) - obstack_alloc (ob, sizeof (struct foo)) -> XOBNEW (ob, struct foo) - obstack_alloc (ob, num * sizeof (struct foo)) -> XOBNEWVEC (ob, struct foo, num) - alloca (sizeof (struct foo)) -> XALLOCA (struct foo) - alloca (num * sizeof (struct foo)) -> XALLOCAVEC (struct foo, num) Some instances of xmalloc followed by memset to zero the buffer were replaced by XCNEW or XCNEWVEC. I regtested on x86-64, Ubuntu 14.04, but the patch touches many architecture-specific files. For those I'll have to rely on the buildbot or people complaining that I broke their gdb. gdb/ChangeLog: * aarch64-linux-nat.c (aarch64_add_process): Likewise. * aarch64-tdep.c (aarch64_gdbarch_init): Likewise. * ada-exp.y (write_ambiguous_var): Likewise. * ada-lang.c (resolve_subexp): Likewise. (user_select_syms): Likewise. (assign_aggregate): Likewise. (ada_evaluate_subexp): Likewise. (cache_symbol): Likewise. * addrmap.c (allocate_key): Likewise. (addrmap_create_mutable): Likewise. * aix-thread.c (sync_threadlists): Likewise. * alpha-tdep.c (alpha_push_dummy_call): Likewise. (alpha_gdbarch_init): Likewise. * amd64-windows-tdep.c (amd64_windows_push_arguments): Likewise. * arm-linux-nat.c (arm_linux_add_process): Likewise. * arm-linux-tdep.c (arm_linux_displaced_step_copy_insn): Likewise. * arm-tdep.c (push_stack_item): Likewise. (arm_displaced_step_copy_insn): Likewise. (arm_gdbarch_init): Likewise. (_initialize_arm_tdep): Likewise. * avr-tdep.c (push_stack_item): Likewise. * ax-general.c (new_agent_expr): Likewise. * block.c (block_initialize_namespace): Likewise. * breakpoint.c (alloc_counted_command_line): Likewise. (update_dprintf_command_list): Likewise. (parse_breakpoint_sals): Likewise. (decode_static_tracepoint_spec): Likewise. (until_break_command): Likewise. (clear_command): Likewise. (update_global_location_list): Likewise. (get_breakpoint_objfile_data) Likewise. * btrace.c (ftrace_new_function): Likewise. (btrace_set_insn_history): Likewise. (btrace_set_call_history): Likewise. * buildsym.c (add_symbol_to_list): Likewise. (record_pending_block): Likewise. (start_subfile): Likewise. (start_buildsym_compunit): Likewise. (push_subfile): Likewise. (end_symtab_get_static_block): Likewise. (buildsym_init): Likewise. * cli/cli-cmds.c (source_command): Likewise. * cli/cli-decode.c (add_cmd): Likewise. * cli/cli-script.c (build_command_line): Likewise. (setup_user_args): Likewise. (realloc_body_list): Likewise. (process_next_line): Likewise. (copy_command_lines): Likewise. * cli/cli-setshow.c (do_set_command): Likewise. * coff-pe-read.c (read_pe_exported_syms): Likewise. * coffread.c (coff_locate_sections): Likewise. (coff_symtab_read): Likewise. (coff_read_struct_type): Likewise. * common/cleanups.c (make_my_cleanup2): Likewise. * common/common-exceptions.c (throw_it): Likewise. * common/filestuff.c (make_cleanup_close): Likewise. * common/format.c (parse_format_string): Likewise. * common/queue.h (DEFINE_QUEUE_P): Likewise. * compile/compile-object-load.c (munmap_list_add): Likewise. (compile_object_load): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * compile/compile.c (append_args): Likewise. * corefile.c (specify_exec_file_hook): Likewise. * cp-support.c (make_symbol_overload_list): Likewise. * cris-tdep.c (push_stack_item): Likewise. (cris_gdbarch_init): Likewise. * ctf.c (ctf_trace_file_writer_new): Likewise. * dbxread.c (init_header_files): Likewise. (add_new_header_file): Likewise. (init_bincl_list): Likewise. (dbx_end_psymtab): Likewise. (start_psymtab): Likewise. (dbx_end_psymtab): Likewise. * dcache.c (dcache_init): Likewise. * dictionary.c (dict_create_hashed): Likewise. (dict_create_hashed_expandable): Likewise. (dict_create_linear): Likewise. (dict_create_linear_expandable): Likewise. * dtrace-probe.c (dtrace_process_dof_probe): Likewise. * dummy-frame.c (register_dummy_frame_dtor): Likewise. * dwarf2-frame-tailcall.c (cache_new_ref1): Likewise. * dwarf2-frame.c (dwarf2_build_frame_info): Likewise. (decode_frame_entry_1): Likewise. * dwarf2expr.c (new_dwarf_expr_context): Likewise. * dwarf2loc.c (dwarf2_compile_expr_to_ax): Likewise. * dwarf2read.c (dwarf2_has_info): Likewise. (create_signatured_type_table_from_index): Likewise. (dwarf2_read_index): Likewise. (dw2_get_file_names_reader): Likewise. (create_all_type_units): Likewise. (read_cutu_die_from_dwo): Likewise. (init_tu_and_read_dwo_dies): Likewise. (init_cutu_and_read_dies): Likewise. (create_all_comp_units): Likewise. (queue_comp_unit): Likewise. (inherit_abstract_dies): Likewise. (read_call_site_scope): Likewise. (dwarf2_add_field): Likewise. (dwarf2_add_typedef): Likewise. (dwarf2_add_member_fn): Likewise. (attr_to_dynamic_prop): Likewise. (abbrev_table_alloc_abbrev): Likewise. (abbrev_table_read_table): Likewise. (add_include_dir): Likewise. (add_file_name): Likewise. (dwarf_decode_line_header): Likewise. (dwarf2_const_value_attr): Likewise. (dwarf_alloc_block): Likewise. (parse_macro_definition): Likewise. (set_die_type): Likewise. (write_psymtabs_to_index): Likewise. (create_cus_from_index): Likewise. (dwarf2_create_include_psymtab): Likewise. (process_psymtab_comp_unit_reader): Likewise. (build_type_psymtab_dependencies): Likewise. (read_comp_units_from_section): Likewise. (compute_compunit_symtab_includes): Likewise. (create_dwo_unit_in_dwp_v1): Likewise. (create_dwo_unit_in_dwp_v2): Likewise. (read_func_scope): Likewise. (process_structure_scope): Likewise. (mark_common_block_symbol_computed): Likewise. (load_partial_dies): Likewise. (dwarf2_symbol_mark_computed): Likewise. * elfread.c (elf_symfile_segments): Likewise. (elf_read_minimal_symbols): Likewise. * environ.c (make_environ): Likewise. * eval.c (evaluate_subexp_standard): Likewise. * event-loop.c (create_file_handler): Likewise. (create_async_signal_handler): Likewise. (create_async_event_handler): Likewise. (create_timer): Likewise. * exec.c (build_section_table): Likewise. * fbsd-nat.c (fbsd_remember_child): Likewise. * fork-child.c (fork_inferior): Likewise. * frv-tdep.c (new_variant): Likewise. * gdbarch.sh (gdbarch_alloc): Likewise. (append_name): Likewise. * gdbtypes.c (rank_function): Likewise. (copy_type_recursive): Likewise. (add_dyn_prop): Likewise. * gnu-nat.c (make_proc): Likewise. (make_inf): Likewise. (gnu_write_inferior): Likewise. * gnu-v3-abi.c (build_gdb_vtable_type): Likewise. (build_std_type_info_type): Likewise. * guile/scm-param.c (compute_enum_list): Likewise. * guile/scm-utils.c (gdbscm_parse_function_args): Likewise. * guile/scm-value.c (gdbscm_value_call): Likewise. * h8300-tdep.c (h8300_gdbarch_init): Likewise. * hppa-tdep.c (hppa_init_objfile_priv_data): Likewise. (read_unwind_info): Likewise. * ia64-tdep.c (ia64_gdbarch_init): Likewise. * infcall.c (dummy_frame_context_saver_setup): Likewise. (call_function_by_hand_dummy): Likewise. * infcmd.c (step_once): Likewise. (finish_forward): Likewise. (attach_command): Likewise. (notice_new_inferior): Likewise. * inferior.c (add_inferior_silent): Likewise. * infrun.c (add_displaced_stepping_state): Likewise. (save_infcall_control_state): Likewise. (save_inferior_ptid): Likewise. (_initialize_infrun): Likewise. * jit.c (bfd_open_from_target_memory): Likewise. (jit_gdbarch_data_init): Likewise. * language.c (add_language): Likewise. * linespec.c (decode_line_2): Likewise. * linux-nat.c (add_to_pid_list): Likewise. (add_initial_lwp): Likewise. * linux-thread-db.c (add_thread_db_info): Likewise. (record_thread): Likewise. (info_auto_load_libthread_db): Likewise. * m32c-tdep.c (m32c_gdbarch_init): Likewise. * m68hc11-tdep.c (m68hc11_gdbarch_init): Likewise. * m68k-tdep.c (m68k_gdbarch_init): Likewise. * m88k-tdep.c (m88k_analyze_prologue): Likewise. * macrocmd.c (macro_define_command): Likewise. * macroexp.c (gather_arguments): Likewise. * macroscope.c (sal_macro_scope): Likewise. * macrotab.c (new_macro_table): Likewise. * mdebugread.c (push_parse_stack): Likewise. (parse_partial_symbols): Likewise. (parse_symbol): Likewise. (psymtab_to_symtab_1): Likewise. (new_block): Likewise. (new_psymtab): Likewise. (mdebug_build_psymtabs): Likewise. (add_pending): Likewise. (elfmdebug_build_psymtabs): Likewise. * mep-tdep.c (mep_gdbarch_init): Likewise. * mi/mi-main.c (mi_execute_command): Likewise. * mi/mi-parse.c (mi_parse_argv): Likewise. * minidebug.c (lzma_open): Likewise. * minsyms.c (terminate_minimal_symbol_table): Likewise. * mips-linux-nat.c (mips_linux_insert_watchpoint): Likewise. * mips-tdep.c (mips_gdbarch_init): Likewise. * mn10300-tdep.c (mn10300_gdbarch_init): Likewise. * msp430-tdep.c (msp430_gdbarch_init): Likewise. * mt-tdep.c (mt_registers_info): Likewise. * nat/aarch64-linux.c (aarch64_linux_new_thread): Likewise. * nat/linux-btrace.c (linux_enable_bts): Likewise. (linux_enable_pt): Likewise. * nat/linux-osdata.c (linux_xfer_osdata_processes): Likewise. (linux_xfer_osdata_processgroups): Likewise. * nios2-tdep.c (nios2_gdbarch_init): Likewise. * nto-procfs.c (procfs_meminfo): Likewise. * objc-lang.c (start_msglist): Likewise. (selectors_info): Likewise. (classes_info): Likewise. (find_methods): Likewise. * objfiles.c (allocate_objfile): Likewise. (update_section_map): Likewise. * osabi.c (gdbarch_register_osabi): Likewise. (gdbarch_register_osabi_sniffer): Likewise. * parse.c (start_arglist): Likewise. * ppc-linux-nat.c (hwdebug_find_thread_points_by_tid): Likewise. (hwdebug_insert_point): Likewise. * printcmd.c (display_command): Likewise. (ui_printf): Likewise. * procfs.c (create_procinfo): Likewise. (load_syscalls): Likewise. (proc_get_LDT_entry): Likewise. (proc_update_threads): Likewise. * prologue-value.c (make_pv_area): Likewise. (pv_area_store): Likewise. * psymtab.c (extend_psymbol_list): Likewise. (init_psymbol_list): Likewise. (allocate_psymtab): Likewise. * python/py-inferior.c (add_thread_object): Likewise. * python/py-param.c (compute_enum_values): Likewise. * python/py-value.c (valpy_call): Likewise. * python/py-varobj.c (py_varobj_iter_next): Likewise. * python/python.c (ensure_python_env): Likewise. * record-btrace.c (record_btrace_start_replaying): Likewise. * record-full.c (record_full_reg_alloc): Likewise. (record_full_mem_alloc): Likewise. (record_full_end_alloc): Likewise. (record_full_core_xfer_partial): Likewise. * regcache.c (get_thread_arch_aspace_regcache): Likewise. * remote-fileio.c (remote_fileio_init_fd_map): Likewise. * remote-notif.c (remote_notif_state_allocate): Likewise. * remote.c (demand_private_info): Likewise. (remote_notif_stop_alloc_reply): Likewise. (remote_enable_btrace): Likewise. * reverse.c (save_bookmark_command): Likewise. * rl78-tdep.c (rl78_gdbarch_init): Likewise. * rx-tdep.c (rx_gdbarch_init): Likewise. * s390-linux-nat.c (s390_insert_watchpoint): Likewise. * ser-go32.c (dos_get_tty_state): Likewise. (dos_copy_tty_state): Likewise. * ser-mingw.c (ser_windows_open): Likewise. (ser_console_wait_handle): Likewise. (ser_console_get_tty_state): Likewise. (make_pipe_state): Likewise. (net_windows_open): Likewise. * ser-unix.c (hardwire_get_tty_state): Likewise. (hardwire_copy_tty_state): Likewise. * solib-aix.c (solib_aix_new_lm_info): Likewise. * solib-dsbt.c (dsbt_current_sos): Likewise. (dsbt_relocate_main_executable): Likewise. * solib-frv.c (frv_current_sos): Likewise. (frv_relocate_main_executable): Likewise. * solib-spu.c (spu_bfd_fopen): Likewise. * solib-svr4.c (lm_info_read): Likewise. (svr4_copy_library_list): Likewise. (svr4_default_sos): Likewise. * source.c (find_source_lines): Likewise. (line_info): Likewise. (add_substitute_path_rule): Likewise. * spu-linux-nat.c (spu_bfd_open): Likewise. * spu-tdep.c (info_spu_dma_cmdlist): Likewise. * stabsread.c (dbx_lookup_type): Likewise. (read_type): Likewise. (read_member_functions): Likewise. (read_struct_fields): Likewise. (read_baseclasses): Likewise. (read_args): Likewise. (_initialize_stabsread): Likewise. * stack.c (func_command): Likewise. * stap-probe.c (handle_stap_probe): Likewise. * symfile.c (addrs_section_sort): Likewise. (addr_info_make_relative): Likewise. (load_section_callback): Likewise. (add_symbol_file_command): Likewise. (init_filename_language_table): Likewise. * symtab.c (create_filename_seen_cache): Likewise. (sort_search_symbols_remove_dups): Likewise. (search_symbols): Likewise. * target.c (make_cleanup_restore_target_terminal): Likewise. * thread.c (new_thread): Likewise. (enable_thread_stack_temporaries): Likewise. (make_cleanup_restore_current_thread): Likewise. (thread_apply_all_command): Likewise. * tic6x-tdep.c (tic6x_gdbarch_init): Likewise. * top.c (gdb_readline_wrapper): Likewise. * tracefile-tfile.c (tfile_trace_file_writer_new): Likewise. * tracepoint.c (trace_find_line_command): Likewise. (all_tracepoint_actions_and_cleanup): Likewise. (make_cleanup_restore_current_traceframe): Likewise. (get_uploaded_tp): Likewise. (get_uploaded_tsv): Likewise. * tui/tui-data.c (tui_alloc_generic_win_info): Likewise. (tui_alloc_win_info): Likewise. (tui_alloc_content): Likewise. (tui_add_content_elements): Likewise. * tui/tui-disasm.c (tui_find_disassembly_address): Likewise. (tui_set_disassem_content): Likewise. * ui-file.c (ui_file_new): Likewise. (stdio_file_new): Likewise. (tee_file_new): Likewise. * utils.c (make_cleanup_restore_integer): Likewise. (add_internal_problem_command): Likewise. * v850-tdep.c (v850_gdbarch_init): Likewise. * valops.c (find_oload_champ): Likewise. * value.c (allocate_value_lazy): Likewise. (record_latest_value): Likewise. (create_internalvar): Likewise. * varobj.c (install_variable): Likewise. (new_variable): Likewise. (new_root_variable): Likewise. (cppush): Likewise. (_initialize_varobj): Likewise. * windows-nat.c (windows_make_so): Likewise. * x86-nat.c (x86_add_process): Likewise. * xcoffread.c (arrange_linetable): Likewise. (allocate_include_entry): Likewise. (process_linenos): Likewise. (SYMBOL_DUP): Likewise. (xcoff_start_psymtab): Likewise. (xcoff_end_psymtab): Likewise. * xml-support.c (gdb_xml_parse_attr_ulongest): Likewise. * xtensa-tdep.c (xtensa_register_type): Likewise. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. gdb/gdbserver/ChangeLog: * ax.c (gdb_parse_agent_expr): Likewise. (compile_bytecodes): Likewise. * dll.c (loaded_dll): Likewise. * event-loop.c (append_callback_event): Likewise. (create_file_handler): Likewise. (create_file_event): Likewise. * hostio.c (handle_open): Likewise. * inferiors.c (add_thread): Likewise. (add_process): Likewise. * linux-aarch64-low.c (aarch64_linux_new_process): Likewise. * linux-arm-low.c (arm_new_process): Likewise. (arm_new_thread): Likewise. * linux-low.c (add_to_pid_list): Likewise. (linux_add_process): Likewise. (handle_extended_wait): Likewise. (add_lwp): Likewise. (enqueue_one_deferred_signal): Likewise. (enqueue_pending_signal): Likewise. (linux_resume_one_lwp_throw): Likewise. (linux_resume_one_thread): Likewise. (linux_read_memory): Likewise. (linux_write_memory): Likewise. * linux-mips-low.c (mips_linux_new_process): Likewise. (mips_linux_new_thread): Likewise. (mips_add_watchpoint): Likewise. * linux-x86-low.c (initialize_low_arch): Likewise. * lynx-low.c (lynx_add_process): Likewise. * mem-break.c (set_raw_breakpoint_at): Likewise. (set_breakpoint): Likewise. (add_condition_to_breakpoint): Likewise. (add_commands_to_breakpoint): Likewise. (clone_agent_expr): Likewise. (clone_one_breakpoint): Likewise. * regcache.c (new_register_cache): Likewise. * remote-utils.c (look_up_one_symbol): Likewise. * server.c (queue_stop_reply): Likewise. (start_inferior): Likewise. (queue_stop_reply_callback): Likewise. (handle_target_event): Likewise. * spu-low.c (fetch_ppc_memory): Likewise. (store_ppc_memory): Likewise. * target.c (set_target_ops): Likewise. * thread-db.c (thread_db_load_search): Likewise. (try_thread_db_load_1): Likewise. * tracepoint.c (add_tracepoint): Likewise. (add_tracepoint_action): Likewise. (create_trace_state_variable): Likewise. (cmd_qtdpsrc): Likewise. (cmd_qtro): Likewise. (add_while_stepping_state): Likewise. * win32-low.c (child_add_thread): Likewise. (get_image_name): Likewise.
2015-08-26 23:16:07 +02:00
proc->priv = XCNEW (struct process_info_private);
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
gdbserver/linux-low: turn process/thread addition/deletion ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'new_process', 'delete_process', 'new_thread', 'delete_thread', and 'new_fork' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <add_linux_process> <add_lwp> <delete_lwp> <attach_lwp> <detach_one_lwp> <check_zombie_leaders> <filter_exit_event> <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. * linux-low.cc (delete_lwp): Turn into... (linux_process_target::delete_lwp): ...this. (linux_process_target::low_delete_thread): Define. (linux_add_process): Turn into... (linux_process_target::add_linux_process): ...this. (linux_process_target::low_new_process): Define. (linux_process_target::low_delete_process): Define. (linux_process_target::low_new_fork): Define. (add_lwp): Turn into... (linux_process_target::add_lwp): ...this. (linux_process_target::low_new_thread): Define. (linux_attach_lwp): Turn into... (linux_process_target::attach_lwp): ...this. (linux_detach_one_lwp): Turn into... (linux_process_target::detach_one_lwp): ...this. (linux_detach_lwp_callback): Remove and inline... (linux_process_target::detach): ...here. (check_zombie_leaders): Turn into... (linux_process_target::check_zombie_leaders): ...this. (filter_exit_event): Turn into... (linux_process_target::filter_exit_event): ...this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::create_inferior) (attach_proc_task_lwp_callback) (linux_process_target::attach) (linux_process_target::detach) (linux_process_target::mourn) * thread-db.cc (attach_thread) * linux-x86-low.cc (class x86_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (x86_linux_new_process): Turn into... (x86_target::low_new_process): ...this. (x86_linux_delete_process): Turn into... (x86_target::low_delete_process): ...this. (x86_target::low_new_thread): Define. (x86_target::low_delete_thread): Define. (x86_linux_new_fork): Turn into... (x86_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (aarch64_linux_new_process): Turn into... (aarch64_target::low_new_process): ...this. (aarch64_linux_delete_process): Turn into... (aarch64_target::low_delete_process): ...this. (aarch64_target::low_new_thread): Define. (aarch64_target::low_delete_thread): Define. (aarch64_linux_new_fork): Turn into... (aarch64_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (arm_new_process): Turn into... (arm_target::low_new_process): ...this. (arm_delete_process): Turn into... (arm_target::low_delete_process): ...this. (arm_new_thread): Turn into... (arm_target::low_new_thread): ...this. (arm_delete_thread): Turn into... (arm_target::low_delete_thread): ...this. (arm_new_fork): Turn into... (arm_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (mips_linux_new_process): Turn into... (mips_target::low_new_process): ...this. (mips_linux_delete_process): Turn into... (mips_target::low_delete_process): ...this. (mips_linux_new_thread): Turn into... (mips_target::low_new_thread): ...this. (mips_linux_delete_thread): Turn into... (mips_target::low_delete_thread): ...this. (mips_linux_new_fork): Turn into... (mips_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:28 +02:00
proc->priv->arch_private = low_new_process ();
Add h/w watchpoint support to x86-linux, win32-i386. * Makefile.in (SFILES): Add i386-low.c (i386_low_h): Define. (i386-low.o): Add dependencies. (linux-x86-low.o): Add i386-low.h dependency. (win32-i386-low.o): Ditto. * i386-low.c: New file. * i386-low.h: New file. * configure.srv (i[34567]86-*-cygwin*): Add i386-low.o to srv_tgtobj. (i[34567]86-*-linux*, i[34567]86-*-mingw*, x86_64-*-linux*): Ditto. * linux-low.c (linux_add_process): Initialize arch_private. (linux_remove_process): Free arch_private. (add_lwp): Initialize arch_private. (delete_lwp): Free arch_private. (linux_resume_one_lwp): Call the_low_target.prepare_to_resume if provided. * linux-low.h (process_info_private): New member arch_private. (lwp_info): New member arch_private. (linux_target_ops): New members new_process, new_thread, prepare_to_resume. (ptid_of): New macro. * linux-x86-low.c: Include stddef.h, i386-low.h. (arch_process_info): New struct. (arch_lwp_info): New struct. (x86_linux_dr_get, x86_linux_dr_set): New functions. (i386_dr_low_set_addr, i386_dr_low_set_control): New functions. (i386_dr_low_get_status): New function. (x86_insert_point, x86_remove_point): New functions. (x86_stopped_by_watchpoint): New function. (x86_stopped_data_address): New function. (x86_linux_new_process, x86_linux_new_thread): New functions. (x86_linux_prepare_to_resume): New function. (the_low_target): Add entries for insert_point, remove_point, stopped_by_watchpoint, stopped_data_address, new_process, new_thread, prepare_to_resume. * server.c (debug_hw_points): New global. (monitor_show_help): Document set debug-hw-points. (handle_query): Process "set debug-hw-points". * server.h (debug_hw_points): Declare. (paddress): Declare. * utils.c (NUMCELLS, CELLSIZE): New macros. (get_sell, xsnprintf, paddress): New functions. * win32-arm-low.c (the_low_target): Add entries for insert_point, remove_point, stopped_by_watchpoint, stopped_data_address. * win32-i386-low.c: Include i386-low.h. (debug_reg_state): Replaces dr. (i386_dr_low_set_addr, i386_dr_low_set_control): New functions. (i386_dr_low_get_status): New function. (i386_insert_point, i386_remove_point): New functions. (i386_stopped_by_watchpoint): New function. (i386_stopped_data_address): New function. (i386_initial_stuff): Update. (get_thread_context,set_thread_context,i386_thread_added): Update. (the_low_target): Add entries for insert_point, remove_point, stopped_by_watchpoint, stopped_data_address. * win32-low.c (win32_insert_watchpoint): New function. (win32_remove_watchpoint): New function. (win32_stopped_by_watchpoint): New function. (win32_stopped_data_address): New function. (win32_target_ops): Add entries for insert_watchpoint, remove_watchpoint, stopped_by_watchpoint, stopped_data_address. * win32-low.h (win32_target_ops): New members insert_point, remove_point, stopped_by_watchpoint, stopped_data_address.
2009-06-30 18:35:25 +02:00
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
return proc;
}
gdbserver/linux-low: turn process/thread addition/deletion ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'new_process', 'delete_process', 'new_thread', 'delete_thread', and 'new_fork' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <add_linux_process> <add_lwp> <delete_lwp> <attach_lwp> <detach_one_lwp> <check_zombie_leaders> <filter_exit_event> <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. * linux-low.cc (delete_lwp): Turn into... (linux_process_target::delete_lwp): ...this. (linux_process_target::low_delete_thread): Define. (linux_add_process): Turn into... (linux_process_target::add_linux_process): ...this. (linux_process_target::low_new_process): Define. (linux_process_target::low_delete_process): Define. (linux_process_target::low_new_fork): Define. (add_lwp): Turn into... (linux_process_target::add_lwp): ...this. (linux_process_target::low_new_thread): Define. (linux_attach_lwp): Turn into... (linux_process_target::attach_lwp): ...this. (linux_detach_one_lwp): Turn into... (linux_process_target::detach_one_lwp): ...this. (linux_detach_lwp_callback): Remove and inline... (linux_process_target::detach): ...here. (check_zombie_leaders): Turn into... (linux_process_target::check_zombie_leaders): ...this. (filter_exit_event): Turn into... (linux_process_target::filter_exit_event): ...this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::create_inferior) (attach_proc_task_lwp_callback) (linux_process_target::attach) (linux_process_target::detach) (linux_process_target::mourn) * thread-db.cc (attach_thread) * linux-x86-low.cc (class x86_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (x86_linux_new_process): Turn into... (x86_target::low_new_process): ...this. (x86_linux_delete_process): Turn into... (x86_target::low_delete_process): ...this. (x86_target::low_new_thread): Define. (x86_target::low_delete_thread): Define. (x86_linux_new_fork): Turn into... (x86_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (aarch64_linux_new_process): Turn into... (aarch64_target::low_new_process): ...this. (aarch64_linux_delete_process): Turn into... (aarch64_target::low_delete_process): ...this. (aarch64_target::low_new_thread): Define. (aarch64_target::low_delete_thread): Define. (aarch64_linux_new_fork): Turn into... (aarch64_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (arm_new_process): Turn into... (arm_target::low_new_process): ...this. (arm_delete_process): Turn into... (arm_target::low_delete_process): ...this. (arm_new_thread): Turn into... (arm_target::low_new_thread): ...this. (arm_delete_thread): Turn into... (arm_target::low_delete_thread): ...this. (arm_new_fork): Turn into... (arm_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (mips_linux_new_process): Turn into... (mips_target::low_new_process): ...this. (mips_linux_delete_process): Turn into... (mips_target::low_delete_process): ...this. (mips_linux_new_thread): Turn into... (mips_target::low_new_thread): ...this. (mips_linux_delete_thread): Turn into... (mips_target::low_delete_thread): ...this. (mips_linux_new_fork): Turn into... (mips_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:28 +02:00
arch_process_info *
linux_process_target::low_new_process ()
{
return nullptr;
}
void
linux_process_target::low_delete_process (arch_process_info *info)
{
/* Default implementation must be overridden if architecture-specific
info exists. */
gdb_assert (info == nullptr);
}
void
linux_process_target::low_new_fork (process_info *parent, process_info *child)
{
/* Nop. */
}
gdbserver/linux-low: turn 'arch_setup' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'arch_setup' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops) <arch_setup>: Delete. (class linux_process_target) <arch_setup_thread> <low_arch_setup>: New declarations. * linux-low.cc (linux_arch_setup): Delete. (linux_arch_setup_thread): Turn into... (linux_process_target::arch_setup_thread): ... this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::post_create_inferior) (linux_process_target::filter_event) * linux-x86-low.cc (class x86_target) <low_arch_setup>: New declaration. (x86_linux_update_xmltarget): Turn into... (x86_target::update_xmltarget): ...this. (x86_linux_process_qsupported): Update the call to x86_linux_update_xmltarget. (x86_arch_setup): Turn into ... (x86_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <low_arch_setup>: New declaration. (aarch64_arch_setup): Turn into ... (aarch64_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (class arm_target) <low_arch_setup>: New declaration. (arm_arch_setup): Turn into ... (arm_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-bfin-low.cc (class bfin_target) <low_arch_setup>: New declaration. (bfin_arch_setup): Turn into ... (bfin_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-cris-low.cc (class cris_target) <low_arch_setup>: New declaration. (cris_arch_setup): Turn into ... (cris_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-crisv32-low.cc (class crisv32_target) <low_arch_setup>: New declaration. (crisv32_arch_setup): Turn into ... (crisv32_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-ia64-low.cc (class ia64_target) <low_arch_setup>: New declaration. (ia64_arch_setup): Turn into ... (ia64_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-m32r-low.cc (class m32r_target) <low_arch_setup>: New declaration. (m32r_arch_setup): Turn into ... (m32r_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-m68k-low.cc (class m68k_target) <low_arch_setup>: New declaration. (m68k_arch_setup): Turn into ... (m68k_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-mips-low.cc (class mips_target) <low_arch_setup>: New declaration. (mips_arch_setup): Turn into ... (mips_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-nios2-low.cc (class nios2_target) <low_arch_setup>: New declaration. (nios2_arch_setup): Turn into ... (nios2_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (class ppc_target) <low_arch_setup>: New declaration. (ppc_arch_setup): Turn into ... (ppc_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-riscv-low.cc (class riscv_target) <low_arch_setup>: New declaration. (riscv_arch_setup): Turn into ... (riscv_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-s390-low.cc (class s390_target) <low_arch_setup>: New declaration. (s390_arch_setup): Turn into ... (s390_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-sh-low.cc (class sh_target) <low_arch_setup>: New declaration. (sh_arch_setup): Turn into ... (sh_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-sparc-low.cc (class sparc_target) <low_arch_setup>: New declaration. (sparc_arch_setup): Turn into ... (sparc_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-tic6x-low.cc (class tic6x_target) <low_arch_setup>: New declaration. (tic6x_arch_setup): Turn into ... (tic6x_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-tile-low.cc (class tile_target) <low_arch_setup>: New declaration. (tile_arch_setup): Turn into ... (tile_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-xtensa-low.cc (class xtensa_target) <low_arch_setup>: New declaration. (xtensa_arch_setup): Turn into ... (xtensa_target::low_arch_setup): ...this. (the_low_target): Remove the op field.
2020-04-02 15:11:23 +02:00
void
linux_process_target::arch_setup_thread (thread_info *thread)
Extended-remote follow-exec This patch implements support for exec events on extended-remote Linux targets. Follow-exec-mode and rerun behave as expected. Catchpoints and test updates are implemented in subsequent patches. This patch was derived from a patch posted last October: https://sourceware.org/ml/gdb-patches/2014-10/msg00877.html. It was originally based on some work done by Luis Machado in 2013. IMPLEMENTATION ---------------- Exec events are enabled via ptrace options. When an exec event is detected by gdbserver, the existing process data, along with all its associated lwp and thread data, is deleted and replaced by data for a new single-threaded process. The new process data is initialized with the appropriate parts of the state of the execing process. This approach takes care of several potential pitfalls, including: * deleting the data for an execing non-leader thread before any wait/sigsuspend occurs * correctly initializing the architecture of the execed process We then report the exec event using a new RSP stop reason, "exec". When GDB receives an "exec" event, it saves the status in the event structure's target_waitstatus field, like what is done for remote fork events. Because the original and execed programs may have different architectures, we skip parsing the section of the stop reply packet that contains register data. The register data will be retrieved later after the inferior's architecture has been set up by infrun.c:follow_exec. At that point the exec event is handled by the existing event handling in GDB. However, a few changes were necessary so that infrun.c:follow_exec could accommodate the remote target. * Where follow-exec-mode "new" is handled, we now call add_inferior_with_spaces instead of add_inferior with separate calls to set up the program and address spaces. The motivation for this is that add_inferior_with_spaces also sets up the initial architecture for the inferior, which is needed later by target_find_description when it calls target_gdbarch. * We call a new target function, target_follow_exec. This function allows us to store the execd_pathname in the inferior, instead of using the static string remote_exec_file from remote.c. The static string didn't work for follow-exec-mode "new", since once you switched to the execed program, the original remote exec-file was lost. The execd_pathname is now stored in the inferior's program space as a REGISTRY field. All of the requisite mechanisms for this are defined in remote.c. gdb/gdbserver/ChangeLog: * linux-low.c (linux_mourn): Static declaration. (linux_arch_setup): Move in front of handle_extended_wait. (linux_arch_setup_thread): New function. (handle_extended_wait): Handle exec events. Call linux_arch_setup_thread. Make event_lwp argument a pointer-to-a-pointer. (check_zombie_leaders): Do not check stopped threads. (linux_low_ptrace_options): Add PTRACE_O_TRACEEXEC. (linux_low_filter_event): Add lwp and thread for exec'ing non-leader thread if leader thread has been deleted. Refactor code into linux_arch_setup_thread and call it. Pass child lwp pointer by reference to handle_extended_wait. (linux_wait_for_event_filtered): Update comment. (linux_wait_1): Prevent clobbering exec event status. (linux_supports_exec_events): New function. (linux_target_ops) <supports_exec_events>: Initialize new member. * lynx-low.c (lynx_target_ops) <supports_exec_events>: Initialize new member. * remote-utils.c (prepare_resume_reply): New stop reason 'exec'. * server.c (report_exec_events): New global variable. (handle_query): Handle qSupported query for exec-events feature. (captured_main): Initialize report_exec_events. * server.h (report_exec_events): Declare new global variable. * target.h (struct target_ops) <supports_exec_events>: New member. (target_supports_exec_events): New macro. * win32-low.c (win32_target_ops) <supports_exec_events>: Initialize new member. gdb/ChangeLog: * infrun.c (follow_exec): Use process-style ptid for exec message. Call add_inferior_with_spaces and target_follow_exec. * nat/linux-ptrace.c (linux_supports_traceexec): New function. * nat/linux-ptrace.h (linux_supports_traceexec): Declare. * remote.c (remote_pspace_data): New static variable. (remote_pspace_data_cleanup): New function. (get_remote_exec_file): New function. (set_remote_exec_file_1): New function. (set_remote_exec_file): New function. (show_remote_exec_file): New function. (remote_exec_file): Delete static variable. (anonymous enum) <PACKET_exec_event_feature> New enumeration constant. (remote_protocol_features): Add entry for exec-events feature. (remote_query_supported): Add client side of qSupported query for exec-events feature. (remote_follow_exec): New function. (remote_parse_stop_reply): Handle 'exec' stop reason. (extended_remote_run, extended_remote_create_inferior): Call get_remote_exec_file and set_remote_exec_file_1. (init_extended_remote_ops) <to_follow_exec>: Initialize new member. (_initialize_remote): Call register_program_space_data_with_cleanup. Call add_packet_config_cmd for remote exec-events feature. Modify call to add_setshow_string_noescape_cmd for exec-file to use new functions set_remote_exec_file and show_remote_exec_file. * target-debug.h, target-delegates.c: Regenerated. * target.c (target_follow_exec): New function. * target.h (struct target_ops) <to_follow_exec>: New member. (target_follow_exec): Declare new function.
2015-09-11 20:06:02 +02:00
{
struct thread_info *saved_thread;
saved_thread = current_thread;
current_thread = thread;
gdbserver/linux-low: turn 'arch_setup' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'arch_setup' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops) <arch_setup>: Delete. (class linux_process_target) <arch_setup_thread> <low_arch_setup>: New declarations. * linux-low.cc (linux_arch_setup): Delete. (linux_arch_setup_thread): Turn into... (linux_process_target::arch_setup_thread): ... this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::post_create_inferior) (linux_process_target::filter_event) * linux-x86-low.cc (class x86_target) <low_arch_setup>: New declaration. (x86_linux_update_xmltarget): Turn into... (x86_target::update_xmltarget): ...this. (x86_linux_process_qsupported): Update the call to x86_linux_update_xmltarget. (x86_arch_setup): Turn into ... (x86_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <low_arch_setup>: New declaration. (aarch64_arch_setup): Turn into ... (aarch64_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (class arm_target) <low_arch_setup>: New declaration. (arm_arch_setup): Turn into ... (arm_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-bfin-low.cc (class bfin_target) <low_arch_setup>: New declaration. (bfin_arch_setup): Turn into ... (bfin_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-cris-low.cc (class cris_target) <low_arch_setup>: New declaration. (cris_arch_setup): Turn into ... (cris_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-crisv32-low.cc (class crisv32_target) <low_arch_setup>: New declaration. (crisv32_arch_setup): Turn into ... (crisv32_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-ia64-low.cc (class ia64_target) <low_arch_setup>: New declaration. (ia64_arch_setup): Turn into ... (ia64_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-m32r-low.cc (class m32r_target) <low_arch_setup>: New declaration. (m32r_arch_setup): Turn into ... (m32r_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-m68k-low.cc (class m68k_target) <low_arch_setup>: New declaration. (m68k_arch_setup): Turn into ... (m68k_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-mips-low.cc (class mips_target) <low_arch_setup>: New declaration. (mips_arch_setup): Turn into ... (mips_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-nios2-low.cc (class nios2_target) <low_arch_setup>: New declaration. (nios2_arch_setup): Turn into ... (nios2_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (class ppc_target) <low_arch_setup>: New declaration. (ppc_arch_setup): Turn into ... (ppc_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-riscv-low.cc (class riscv_target) <low_arch_setup>: New declaration. (riscv_arch_setup): Turn into ... (riscv_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-s390-low.cc (class s390_target) <low_arch_setup>: New declaration. (s390_arch_setup): Turn into ... (s390_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-sh-low.cc (class sh_target) <low_arch_setup>: New declaration. (sh_arch_setup): Turn into ... (sh_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-sparc-low.cc (class sparc_target) <low_arch_setup>: New declaration. (sparc_arch_setup): Turn into ... (sparc_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-tic6x-low.cc (class tic6x_target) <low_arch_setup>: New declaration. (tic6x_arch_setup): Turn into ... (tic6x_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-tile-low.cc (class tile_target) <low_arch_setup>: New declaration. (tile_arch_setup): Turn into ... (tile_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-xtensa-low.cc (class xtensa_target) <low_arch_setup>: New declaration. (xtensa_arch_setup): Turn into ... (xtensa_target::low_arch_setup): ...this. (the_low_target): Remove the op field.
2020-04-02 15:11:23 +02:00
low_arch_setup ();
Extended-remote follow-exec This patch implements support for exec events on extended-remote Linux targets. Follow-exec-mode and rerun behave as expected. Catchpoints and test updates are implemented in subsequent patches. This patch was derived from a patch posted last October: https://sourceware.org/ml/gdb-patches/2014-10/msg00877.html. It was originally based on some work done by Luis Machado in 2013. IMPLEMENTATION ---------------- Exec events are enabled via ptrace options. When an exec event is detected by gdbserver, the existing process data, along with all its associated lwp and thread data, is deleted and replaced by data for a new single-threaded process. The new process data is initialized with the appropriate parts of the state of the execing process. This approach takes care of several potential pitfalls, including: * deleting the data for an execing non-leader thread before any wait/sigsuspend occurs * correctly initializing the architecture of the execed process We then report the exec event using a new RSP stop reason, "exec". When GDB receives an "exec" event, it saves the status in the event structure's target_waitstatus field, like what is done for remote fork events. Because the original and execed programs may have different architectures, we skip parsing the section of the stop reply packet that contains register data. The register data will be retrieved later after the inferior's architecture has been set up by infrun.c:follow_exec. At that point the exec event is handled by the existing event handling in GDB. However, a few changes were necessary so that infrun.c:follow_exec could accommodate the remote target. * Where follow-exec-mode "new" is handled, we now call add_inferior_with_spaces instead of add_inferior with separate calls to set up the program and address spaces. The motivation for this is that add_inferior_with_spaces also sets up the initial architecture for the inferior, which is needed later by target_find_description when it calls target_gdbarch. * We call a new target function, target_follow_exec. This function allows us to store the execd_pathname in the inferior, instead of using the static string remote_exec_file from remote.c. The static string didn't work for follow-exec-mode "new", since once you switched to the execed program, the original remote exec-file was lost. The execd_pathname is now stored in the inferior's program space as a REGISTRY field. All of the requisite mechanisms for this are defined in remote.c. gdb/gdbserver/ChangeLog: * linux-low.c (linux_mourn): Static declaration. (linux_arch_setup): Move in front of handle_extended_wait. (linux_arch_setup_thread): New function. (handle_extended_wait): Handle exec events. Call linux_arch_setup_thread. Make event_lwp argument a pointer-to-a-pointer. (check_zombie_leaders): Do not check stopped threads. (linux_low_ptrace_options): Add PTRACE_O_TRACEEXEC. (linux_low_filter_event): Add lwp and thread for exec'ing non-leader thread if leader thread has been deleted. Refactor code into linux_arch_setup_thread and call it. Pass child lwp pointer by reference to handle_extended_wait. (linux_wait_for_event_filtered): Update comment. (linux_wait_1): Prevent clobbering exec event status. (linux_supports_exec_events): New function. (linux_target_ops) <supports_exec_events>: Initialize new member. * lynx-low.c (lynx_target_ops) <supports_exec_events>: Initialize new member. * remote-utils.c (prepare_resume_reply): New stop reason 'exec'. * server.c (report_exec_events): New global variable. (handle_query): Handle qSupported query for exec-events feature. (captured_main): Initialize report_exec_events. * server.h (report_exec_events): Declare new global variable. * target.h (struct target_ops) <supports_exec_events>: New member. (target_supports_exec_events): New macro. * win32-low.c (win32_target_ops) <supports_exec_events>: Initialize new member. gdb/ChangeLog: * infrun.c (follow_exec): Use process-style ptid for exec message. Call add_inferior_with_spaces and target_follow_exec. * nat/linux-ptrace.c (linux_supports_traceexec): New function. * nat/linux-ptrace.h (linux_supports_traceexec): Declare. * remote.c (remote_pspace_data): New static variable. (remote_pspace_data_cleanup): New function. (get_remote_exec_file): New function. (set_remote_exec_file_1): New function. (set_remote_exec_file): New function. (show_remote_exec_file): New function. (remote_exec_file): Delete static variable. (anonymous enum) <PACKET_exec_event_feature> New enumeration constant. (remote_protocol_features): Add entry for exec-events feature. (remote_query_supported): Add client side of qSupported query for exec-events feature. (remote_follow_exec): New function. (remote_parse_stop_reply): Handle 'exec' stop reason. (extended_remote_run, extended_remote_create_inferior): Call get_remote_exec_file and set_remote_exec_file_1. (init_extended_remote_ops) <to_follow_exec>: Initialize new member. (_initialize_remote): Call register_program_space_data_with_cleanup. Call add_packet_config_cmd for remote exec-events feature. Modify call to add_setshow_string_noescape_cmd for exec-file to use new functions set_remote_exec_file and show_remote_exec_file. * target-debug.h, target-delegates.c: Regenerated. * target.c (target_follow_exec): New function. * target.h (struct target_ops) <to_follow_exec>: New member. (target_follow_exec): Declare new function.
2015-09-11 20:06:02 +02:00
current_thread = saved_thread;
}
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
int
linux_process_target::handle_extended_wait (lwp_info **orig_event_lwp,
int wstat)
* inferiors.c (change_inferior_id): Delete. (add_pid_to_list, pull_pid_from_list): New. * linux-low.c (PTRACE_SETOPTIONS, PTRACE_GETEVENTMSG) (PTRACE_O_TRACESYSGOOD, PTRACE_O_TRACEFORK, PTRACE_O_TRACEVFORK) (PTRACE_O_TRACECLONE, PTRACE_O_TRACEEXEC, PTRACE_O_TRACEVFORKDONE) (PTRACE_O_TRACEEXIT, PTRACE_EVENT_FORK, PTRACE_EVENT_VFORK) (PTRACE_EVENT_CLONE, PTRACE_EVENT_EXEC, PTRACE_EVENT_VFORK_DONE) (PTRACE_EVENT_EXIT, __WALL): Provide default definitions. (stopped_pids, thread_db_active, must_set_ptrace_flags): New variables. (using_threads): Always set to 1. (handle_extended_wait): New. (add_process): Do not set TID. (linux_create_inferior): Set must_set_ptrace_flags. (linux_attach_lwp): Remove TID argument. Do not check using_threads. Use PTRACE_SETOPTIONS. Call new_thread_notify. Update all callers. (linux_thread_alive): Rename TID argument to LWPID. (linux_wait_for_process): Handle unknown processes. Do not use TID. (linux_wait_for_event): Do not use TID or check using_threads. Update call to dead_thread_notify. Call handle_extended_wait. (linux_create_inferior): Use PTRACE_SETOPTIONS. (send_sigstop): Delete sigstop_sent. (wait_for_sigstop): Avoid TID. (linux_supports_tracefork_flag, linux_tracefork_child, my_waitpid) (linux_test_for_tracefork): New. (linux_lookup_signals): Use thread_db_active and linux_supports_tracefork_flag. (initialize_low): Use thread_db_active and linux_test_for_tracefork. * linux-low.h (get_process_thread): Avoid TID. (struct process_ifo): Move thread_known and tid to the end. Remove sigstop_sent. (linux_attach_lwp, thread_db_init): Update prototypes. * server.h (change_inferior_id): Delete prototype. (add_pid_to_list, pull_pid_from_list): New prototypes. * thread-db.c (thread_db_use_events): New. (find_first_thread): Rename to... (find_one_thread): ...this. Update callers and messages. Do not call fatal. Check thread_db_use_events. Do not call change_inferior_id or new_thread_notify. (maybe_attach_thread): Update. Do not call new_thread_notify. (thread_db_init): Set thread_db_use_events. Check use_events. * utils.c (fatal, warning): Correct message prefix.
2007-10-23 22:05:03 +02:00
{
client_state &cs = get_client_state ();
Extended-remote follow-exec This patch implements support for exec events on extended-remote Linux targets. Follow-exec-mode and rerun behave as expected. Catchpoints and test updates are implemented in subsequent patches. This patch was derived from a patch posted last October: https://sourceware.org/ml/gdb-patches/2014-10/msg00877.html. It was originally based on some work done by Luis Machado in 2013. IMPLEMENTATION ---------------- Exec events are enabled via ptrace options. When an exec event is detected by gdbserver, the existing process data, along with all its associated lwp and thread data, is deleted and replaced by data for a new single-threaded process. The new process data is initialized with the appropriate parts of the state of the execing process. This approach takes care of several potential pitfalls, including: * deleting the data for an execing non-leader thread before any wait/sigsuspend occurs * correctly initializing the architecture of the execed process We then report the exec event using a new RSP stop reason, "exec". When GDB receives an "exec" event, it saves the status in the event structure's target_waitstatus field, like what is done for remote fork events. Because the original and execed programs may have different architectures, we skip parsing the section of the stop reply packet that contains register data. The register data will be retrieved later after the inferior's architecture has been set up by infrun.c:follow_exec. At that point the exec event is handled by the existing event handling in GDB. However, a few changes were necessary so that infrun.c:follow_exec could accommodate the remote target. * Where follow-exec-mode "new" is handled, we now call add_inferior_with_spaces instead of add_inferior with separate calls to set up the program and address spaces. The motivation for this is that add_inferior_with_spaces also sets up the initial architecture for the inferior, which is needed later by target_find_description when it calls target_gdbarch. * We call a new target function, target_follow_exec. This function allows us to store the execd_pathname in the inferior, instead of using the static string remote_exec_file from remote.c. The static string didn't work for follow-exec-mode "new", since once you switched to the execed program, the original remote exec-file was lost. The execd_pathname is now stored in the inferior's program space as a REGISTRY field. All of the requisite mechanisms for this are defined in remote.c. gdb/gdbserver/ChangeLog: * linux-low.c (linux_mourn): Static declaration. (linux_arch_setup): Move in front of handle_extended_wait. (linux_arch_setup_thread): New function. (handle_extended_wait): Handle exec events. Call linux_arch_setup_thread. Make event_lwp argument a pointer-to-a-pointer. (check_zombie_leaders): Do not check stopped threads. (linux_low_ptrace_options): Add PTRACE_O_TRACEEXEC. (linux_low_filter_event): Add lwp and thread for exec'ing non-leader thread if leader thread has been deleted. Refactor code into linux_arch_setup_thread and call it. Pass child lwp pointer by reference to handle_extended_wait. (linux_wait_for_event_filtered): Update comment. (linux_wait_1): Prevent clobbering exec event status. (linux_supports_exec_events): New function. (linux_target_ops) <supports_exec_events>: Initialize new member. * lynx-low.c (lynx_target_ops) <supports_exec_events>: Initialize new member. * remote-utils.c (prepare_resume_reply): New stop reason 'exec'. * server.c (report_exec_events): New global variable. (handle_query): Handle qSupported query for exec-events feature. (captured_main): Initialize report_exec_events. * server.h (report_exec_events): Declare new global variable. * target.h (struct target_ops) <supports_exec_events>: New member. (target_supports_exec_events): New macro. * win32-low.c (win32_target_ops) <supports_exec_events>: Initialize new member. gdb/ChangeLog: * infrun.c (follow_exec): Use process-style ptid for exec message. Call add_inferior_with_spaces and target_follow_exec. * nat/linux-ptrace.c (linux_supports_traceexec): New function. * nat/linux-ptrace.h (linux_supports_traceexec): Declare. * remote.c (remote_pspace_data): New static variable. (remote_pspace_data_cleanup): New function. (get_remote_exec_file): New function. (set_remote_exec_file_1): New function. (set_remote_exec_file): New function. (show_remote_exec_file): New function. (remote_exec_file): Delete static variable. (anonymous enum) <PACKET_exec_event_feature> New enumeration constant. (remote_protocol_features): Add entry for exec-events feature. (remote_query_supported): Add client side of qSupported query for exec-events feature. (remote_follow_exec): New function. (remote_parse_stop_reply): Handle 'exec' stop reason. (extended_remote_run, extended_remote_create_inferior): Call get_remote_exec_file and set_remote_exec_file_1. (init_extended_remote_ops) <to_follow_exec>: Initialize new member. (_initialize_remote): Call register_program_space_data_with_cleanup. Call add_packet_config_cmd for remote exec-events feature. Modify call to add_setshow_string_noescape_cmd for exec-file to use new functions set_remote_exec_file and show_remote_exec_file. * target-debug.h, target-delegates.c: Regenerated. * target.c (target_follow_exec): New function. * target.h (struct target_ops) <to_follow_exec>: New member. (target_follow_exec): Declare new function.
2015-09-11 20:06:02 +02:00
struct lwp_info *event_lwp = *orig_event_lwp;
int event = linux_ptrace_get_extended_event (wstat);
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
struct thread_info *event_thr = get_lwp_thread (event_lwp);
Rename "process" to "lwp" throughout. * linux-low.c (all_processes): Rename to... (all_lwps): ... this. (inferior_pid, handle_extended_wait, get_stop_pc): Adjust. (add_process): Rename to ... (add_lwp): ... this. Adjust. (linux_create_inferior): Adjust. (linux_attach_lwp): Adjust. (linux_attach): Adjust. (linux_kill_one_process): Rename to ... (linux_kill_one_lwp): ... this. Adjust. (linux_kill): Adjust. (linux_detach_one_process): Rename to ... (linux_detach_one_lwp): ... this. Adjust. (linux_detach): Adjust. (check_removed_breakpoint): Adjust. (status_pending_p): Adjust. (linux_wait_for_process): Rename to ... (linux_wait_for_lwp): ... this. Adjust. (linux_wait_for_event): Adjust. (send_sigstop): Adjust. (wait_for_sigstop): Adjust. (stop_all_processes): Rename to ... (stop_all_lwps): ... this. (linux_resume_one_process): Rename to ... (linux_resume_one_lwp): ... this. Adjust. (linux_set_resume_request, linux_continue_one_thread) (linux_queue_one_thread, resume_status_pending_p) (usr_store_inferior_registers, regsets_store_inferior_registers) (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Adjust. * linux-low.h (get_process): Rename to ... (get_lwp): ... this. Adjust. (get_thread_process): Rename to ... (get_thread_lwp): ... this. Adjust. (get_process_thread): Rename to ... (get_lwp_thread): ... this. Adjust. (struct process_info): Rename to ... (struct lwp_info): ... this. (all_processes): Rename to ... (all_lwps): ... this. * proc-service.c (ps_lgetregs): Adjust. * thread-db.c (thread_db_create_event, find_one_thread) (maybe_attach_thread, thread_db_get_tls_address): Adjust.
2009-03-17 21:25:35 +01:00
struct lwp_info *new_lwp;
* inferiors.c (change_inferior_id): Delete. (add_pid_to_list, pull_pid_from_list): New. * linux-low.c (PTRACE_SETOPTIONS, PTRACE_GETEVENTMSG) (PTRACE_O_TRACESYSGOOD, PTRACE_O_TRACEFORK, PTRACE_O_TRACEVFORK) (PTRACE_O_TRACECLONE, PTRACE_O_TRACEEXEC, PTRACE_O_TRACEVFORKDONE) (PTRACE_O_TRACEEXIT, PTRACE_EVENT_FORK, PTRACE_EVENT_VFORK) (PTRACE_EVENT_CLONE, PTRACE_EVENT_EXEC, PTRACE_EVENT_VFORK_DONE) (PTRACE_EVENT_EXIT, __WALL): Provide default definitions. (stopped_pids, thread_db_active, must_set_ptrace_flags): New variables. (using_threads): Always set to 1. (handle_extended_wait): New. (add_process): Do not set TID. (linux_create_inferior): Set must_set_ptrace_flags. (linux_attach_lwp): Remove TID argument. Do not check using_threads. Use PTRACE_SETOPTIONS. Call new_thread_notify. Update all callers. (linux_thread_alive): Rename TID argument to LWPID. (linux_wait_for_process): Handle unknown processes. Do not use TID. (linux_wait_for_event): Do not use TID or check using_threads. Update call to dead_thread_notify. Call handle_extended_wait. (linux_create_inferior): Use PTRACE_SETOPTIONS. (send_sigstop): Delete sigstop_sent. (wait_for_sigstop): Avoid TID. (linux_supports_tracefork_flag, linux_tracefork_child, my_waitpid) (linux_test_for_tracefork): New. (linux_lookup_signals): Use thread_db_active and linux_supports_tracefork_flag. (initialize_low): Use thread_db_active and linux_test_for_tracefork. * linux-low.h (get_process_thread): Avoid TID. (struct process_ifo): Move thread_known and tid to the end. Remove sigstop_sent. (linux_attach_lwp, thread_db_init): Update prototypes. * server.h (change_inferior_id): Delete prototype. (add_pid_to_list, pull_pid_from_list): New prototypes. * thread-db.c (thread_db_use_events): New. (find_first_thread): Rename to... (find_one_thread): ...this. Update callers and messages. Do not call fatal. Check thread_db_use_events. Do not call change_inferior_id or new_thread_notify. (maybe_attach_thread): Update. Do not call new_thread_notify. (thread_db_init): Set thread_db_use_events. Check use_events. * utils.c (fatal, warning): Correct message prefix.
2007-10-23 22:05:03 +02:00
Remote thread create/exit events When testing with "maint set target-non-stop on", a few threading-related tests expose an issue that requires new RSP packets. Say there are 3 threads running, 1-3. If GDB tries to stop thread 1, 2 and 3, and then waits for their stops, but meanwhile say, thread 2 exits, GDB hangs forever waiting for a stop for thread 2 that won't ever happen. This patch fixes the issue by adding support for thread exit events to the protocol. However, we don't want these always enabled, as they're useless most of the time, and would slow down remote debugging. So I made it so that GDB can enable/disable them, and then made gdb do that around the cases that need it, which currently is only infrun.c:stop_all_threads. In turn, if we have thread exit events, then the extra "thread x exited" traffic slows down attach-many-short-lived-threads.exp enough that gdb has trouble keeping up with new threads that are spawned while gdb tries to stop existing ones. To fix that I added support for the counterpart thread created events too. Enabling those when we try to stop threads ensures that new threads never get a chance to themselves start new threads, killing the race. gdb/doc/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): List "set/show remote thread-events" command in configuration table. (Stop Reply Packets): Document "T05 create" stop reason and 'w' stop reply. (General Query Packets): Document QThreadEvents packet. Document QThreadEvents qSupported feature. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. If GDB wants to hear about thread create events, leave the new child's status pending. (linux_low_filter_event): If GDB wants to hear about thread exit events, leave the LWP marked dead and don't delete it. (linux_wait_for_event_filtered): Don't check for thread exit. (filter_exit_event): New function. (linux_wait_1): Use it, when returning an exit event. (linux_resume_one_lwp_throw): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. * remote-utils.c (prepare_resume_reply): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.c (report_thread_events): New global. (handle_general_set): Handle QThreadEvents. (handle_query) <qSupported>: Handle and report QThreadEvents+; (handle_target_event): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.h (report_thread_events): Declare. gdb/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * NEWS (New commands): Mention "set/show remote thread-events" commands. (New remote packets): Mention thread created/exited stop reasons and QThreadEvents packet. * infrun.c (disable_thread_events): New function. (stop_all_threads): Disable/enable thread create/exit events. Handle TARGET_WAITKIND_THREAD_EXITED. (handle_inferior_event_1): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * remote.c (remove_child_of_pending_fork): Also remove threads of threads that have TARGET_WAITKIND_THREAD_EXITED events. (remote_parse_stop_reply): Handle "create" magic register. Handle 'w' stop reply. (initialize_remote): Install remote_thread_events as to_thread_events target hook. (remote_thread_events): New function. * target-delegates.c: Regenerate. * target.c (target_thread_events): New function. * target.h (struct target_ops) <to_thread_events>: New field. (target_thread_events): Declare. * target/waitstatus.c (target_waitstatus_to_string): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * target/waitstatus.h (enum target_waitkind) <TARGET_WAITKIND_THREAD_CREATED, TARGET_WAITKIND_THREAD_EXITED): New values.
2015-11-30 17:05:21 +01:00
gdb_assert (event_lwp->waitstatus.kind == TARGET_WAITKIND_IGNORE);
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
/* All extended events we currently use are mid-syscall. Only
PTRACE_EVENT_STOP is delivered more like a signal-stop, but
you have to be using PTRACE_SEIZE to get that. */
event_lwp->syscall_state = TARGET_WAITKIND_SYSCALL_ENTRY;
2015-05-12 18:52:45 +02:00
if ((event == PTRACE_EVENT_FORK) || (event == PTRACE_EVENT_VFORK)
|| (event == PTRACE_EVENT_CLONE))
* inferiors.c (change_inferior_id): Delete. (add_pid_to_list, pull_pid_from_list): New. * linux-low.c (PTRACE_SETOPTIONS, PTRACE_GETEVENTMSG) (PTRACE_O_TRACESYSGOOD, PTRACE_O_TRACEFORK, PTRACE_O_TRACEVFORK) (PTRACE_O_TRACECLONE, PTRACE_O_TRACEEXEC, PTRACE_O_TRACEVFORKDONE) (PTRACE_O_TRACEEXIT, PTRACE_EVENT_FORK, PTRACE_EVENT_VFORK) (PTRACE_EVENT_CLONE, PTRACE_EVENT_EXEC, PTRACE_EVENT_VFORK_DONE) (PTRACE_EVENT_EXIT, __WALL): Provide default definitions. (stopped_pids, thread_db_active, must_set_ptrace_flags): New variables. (using_threads): Always set to 1. (handle_extended_wait): New. (add_process): Do not set TID. (linux_create_inferior): Set must_set_ptrace_flags. (linux_attach_lwp): Remove TID argument. Do not check using_threads. Use PTRACE_SETOPTIONS. Call new_thread_notify. Update all callers. (linux_thread_alive): Rename TID argument to LWPID. (linux_wait_for_process): Handle unknown processes. Do not use TID. (linux_wait_for_event): Do not use TID or check using_threads. Update call to dead_thread_notify. Call handle_extended_wait. (linux_create_inferior): Use PTRACE_SETOPTIONS. (send_sigstop): Delete sigstop_sent. (wait_for_sigstop): Avoid TID. (linux_supports_tracefork_flag, linux_tracefork_child, my_waitpid) (linux_test_for_tracefork): New. (linux_lookup_signals): Use thread_db_active and linux_supports_tracefork_flag. (initialize_low): Use thread_db_active and linux_test_for_tracefork. * linux-low.h (get_process_thread): Avoid TID. (struct process_ifo): Move thread_known and tid to the end. Remove sigstop_sent. (linux_attach_lwp, thread_db_init): Update prototypes. * server.h (change_inferior_id): Delete prototype. (add_pid_to_list, pull_pid_from_list): New prototypes. * thread-db.c (thread_db_use_events): New. (find_first_thread): Rename to... (find_one_thread): ...this. Update callers and messages. Do not call fatal. Check thread_db_use_events. Do not call change_inferior_id or new_thread_notify. (maybe_attach_thread): Update. Do not call new_thread_notify. (thread_db_init): Set thread_db_use_events. Check use_events. * utils.c (fatal, warning): Correct message prefix.
2007-10-23 22:05:03 +02:00
{
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
ptid_t ptid;
* inferiors.c (change_inferior_id): Delete. (add_pid_to_list, pull_pid_from_list): New. * linux-low.c (PTRACE_SETOPTIONS, PTRACE_GETEVENTMSG) (PTRACE_O_TRACESYSGOOD, PTRACE_O_TRACEFORK, PTRACE_O_TRACEVFORK) (PTRACE_O_TRACECLONE, PTRACE_O_TRACEEXEC, PTRACE_O_TRACEVFORKDONE) (PTRACE_O_TRACEEXIT, PTRACE_EVENT_FORK, PTRACE_EVENT_VFORK) (PTRACE_EVENT_CLONE, PTRACE_EVENT_EXEC, PTRACE_EVENT_VFORK_DONE) (PTRACE_EVENT_EXIT, __WALL): Provide default definitions. (stopped_pids, thread_db_active, must_set_ptrace_flags): New variables. (using_threads): Always set to 1. (handle_extended_wait): New. (add_process): Do not set TID. (linux_create_inferior): Set must_set_ptrace_flags. (linux_attach_lwp): Remove TID argument. Do not check using_threads. Use PTRACE_SETOPTIONS. Call new_thread_notify. Update all callers. (linux_thread_alive): Rename TID argument to LWPID. (linux_wait_for_process): Handle unknown processes. Do not use TID. (linux_wait_for_event): Do not use TID or check using_threads. Update call to dead_thread_notify. Call handle_extended_wait. (linux_create_inferior): Use PTRACE_SETOPTIONS. (send_sigstop): Delete sigstop_sent. (wait_for_sigstop): Avoid TID. (linux_supports_tracefork_flag, linux_tracefork_child, my_waitpid) (linux_test_for_tracefork): New. (linux_lookup_signals): Use thread_db_active and linux_supports_tracefork_flag. (initialize_low): Use thread_db_active and linux_test_for_tracefork. * linux-low.h (get_process_thread): Avoid TID. (struct process_ifo): Move thread_known and tid to the end. Remove sigstop_sent. (linux_attach_lwp, thread_db_init): Update prototypes. * server.h (change_inferior_id): Delete prototype. (add_pid_to_list, pull_pid_from_list): New prototypes. * thread-db.c (thread_db_use_events): New. (find_first_thread): Rename to... (find_one_thread): ...this. Update callers and messages. Do not call fatal. Check thread_db_use_events. Do not call change_inferior_id or new_thread_notify. (maybe_attach_thread): Update. Do not call new_thread_notify. (thread_db_init): Set thread_db_use_events. Check use_events. * utils.c (fatal, warning): Correct message prefix.
2007-10-23 22:05:03 +02:00
unsigned long new_pid;
int ret, status;
* inferiors.c (change_inferior_id): Delete. (add_pid_to_list, pull_pid_from_list): New. * linux-low.c (PTRACE_SETOPTIONS, PTRACE_GETEVENTMSG) (PTRACE_O_TRACESYSGOOD, PTRACE_O_TRACEFORK, PTRACE_O_TRACEVFORK) (PTRACE_O_TRACECLONE, PTRACE_O_TRACEEXEC, PTRACE_O_TRACEVFORKDONE) (PTRACE_O_TRACEEXIT, PTRACE_EVENT_FORK, PTRACE_EVENT_VFORK) (PTRACE_EVENT_CLONE, PTRACE_EVENT_EXEC, PTRACE_EVENT_VFORK_DONE) (PTRACE_EVENT_EXIT, __WALL): Provide default definitions. (stopped_pids, thread_db_active, must_set_ptrace_flags): New variables. (using_threads): Always set to 1. (handle_extended_wait): New. (add_process): Do not set TID. (linux_create_inferior): Set must_set_ptrace_flags. (linux_attach_lwp): Remove TID argument. Do not check using_threads. Use PTRACE_SETOPTIONS. Call new_thread_notify. Update all callers. (linux_thread_alive): Rename TID argument to LWPID. (linux_wait_for_process): Handle unknown processes. Do not use TID. (linux_wait_for_event): Do not use TID or check using_threads. Update call to dead_thread_notify. Call handle_extended_wait. (linux_create_inferior): Use PTRACE_SETOPTIONS. (send_sigstop): Delete sigstop_sent. (wait_for_sigstop): Avoid TID. (linux_supports_tracefork_flag, linux_tracefork_child, my_waitpid) (linux_test_for_tracefork): New. (linux_lookup_signals): Use thread_db_active and linux_supports_tracefork_flag. (initialize_low): Use thread_db_active and linux_test_for_tracefork. * linux-low.h (get_process_thread): Avoid TID. (struct process_ifo): Move thread_known and tid to the end. Remove sigstop_sent. (linux_attach_lwp, thread_db_init): Update prototypes. * server.h (change_inferior_id): Delete prototype. (add_pid_to_list, pull_pid_from_list): New prototypes. * thread-db.c (thread_db_use_events): New. (find_first_thread): Rename to... (find_one_thread): ...this. Update callers and messages. Do not call fatal. Check thread_db_use_events. Do not call change_inferior_id or new_thread_notify. (maybe_attach_thread): Update. Do not call new_thread_notify. (thread_db_init): Set thread_db_use_events. Check use_events. * utils.c (fatal, warning): Correct message prefix.
2007-10-23 22:05:03 +02:00
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
/* Get the pid of the new lwp. */
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
ptrace (PTRACE_GETEVENTMSG, lwpid_of (event_thr), (PTRACE_TYPE_ARG3) 0,
&new_pid);
* inferiors.c (change_inferior_id): Delete. (add_pid_to_list, pull_pid_from_list): New. * linux-low.c (PTRACE_SETOPTIONS, PTRACE_GETEVENTMSG) (PTRACE_O_TRACESYSGOOD, PTRACE_O_TRACEFORK, PTRACE_O_TRACEVFORK) (PTRACE_O_TRACECLONE, PTRACE_O_TRACEEXEC, PTRACE_O_TRACEVFORKDONE) (PTRACE_O_TRACEEXIT, PTRACE_EVENT_FORK, PTRACE_EVENT_VFORK) (PTRACE_EVENT_CLONE, PTRACE_EVENT_EXEC, PTRACE_EVENT_VFORK_DONE) (PTRACE_EVENT_EXIT, __WALL): Provide default definitions. (stopped_pids, thread_db_active, must_set_ptrace_flags): New variables. (using_threads): Always set to 1. (handle_extended_wait): New. (add_process): Do not set TID. (linux_create_inferior): Set must_set_ptrace_flags. (linux_attach_lwp): Remove TID argument. Do not check using_threads. Use PTRACE_SETOPTIONS. Call new_thread_notify. Update all callers. (linux_thread_alive): Rename TID argument to LWPID. (linux_wait_for_process): Handle unknown processes. Do not use TID. (linux_wait_for_event): Do not use TID or check using_threads. Update call to dead_thread_notify. Call handle_extended_wait. (linux_create_inferior): Use PTRACE_SETOPTIONS. (send_sigstop): Delete sigstop_sent. (wait_for_sigstop): Avoid TID. (linux_supports_tracefork_flag, linux_tracefork_child, my_waitpid) (linux_test_for_tracefork): New. (linux_lookup_signals): Use thread_db_active and linux_supports_tracefork_flag. (initialize_low): Use thread_db_active and linux_test_for_tracefork. * linux-low.h (get_process_thread): Avoid TID. (struct process_ifo): Move thread_known and tid to the end. Remove sigstop_sent. (linux_attach_lwp, thread_db_init): Update prototypes. * server.h (change_inferior_id): Delete prototype. (add_pid_to_list, pull_pid_from_list): New prototypes. * thread-db.c (thread_db_use_events): New. (find_first_thread): Rename to... (find_one_thread): ...this. Update callers and messages. Do not call fatal. Check thread_db_use_events. Do not call change_inferior_id or new_thread_notify. (maybe_attach_thread): Update. Do not call new_thread_notify. (thread_db_init): Set thread_db_use_events. Check use_events. * utils.c (fatal, warning): Correct message prefix.
2007-10-23 22:05:03 +02:00
/* If we haven't already seen the new PID stop, wait for it now. */
if (!pull_pid_from_list (&stopped_pids, new_pid, &status))
* inferiors.c (change_inferior_id): Delete. (add_pid_to_list, pull_pid_from_list): New. * linux-low.c (PTRACE_SETOPTIONS, PTRACE_GETEVENTMSG) (PTRACE_O_TRACESYSGOOD, PTRACE_O_TRACEFORK, PTRACE_O_TRACEVFORK) (PTRACE_O_TRACECLONE, PTRACE_O_TRACEEXEC, PTRACE_O_TRACEVFORKDONE) (PTRACE_O_TRACEEXIT, PTRACE_EVENT_FORK, PTRACE_EVENT_VFORK) (PTRACE_EVENT_CLONE, PTRACE_EVENT_EXEC, PTRACE_EVENT_VFORK_DONE) (PTRACE_EVENT_EXIT, __WALL): Provide default definitions. (stopped_pids, thread_db_active, must_set_ptrace_flags): New variables. (using_threads): Always set to 1. (handle_extended_wait): New. (add_process): Do not set TID. (linux_create_inferior): Set must_set_ptrace_flags. (linux_attach_lwp): Remove TID argument. Do not check using_threads. Use PTRACE_SETOPTIONS. Call new_thread_notify. Update all callers. (linux_thread_alive): Rename TID argument to LWPID. (linux_wait_for_process): Handle unknown processes. Do not use TID. (linux_wait_for_event): Do not use TID or check using_threads. Update call to dead_thread_notify. Call handle_extended_wait. (linux_create_inferior): Use PTRACE_SETOPTIONS. (send_sigstop): Delete sigstop_sent. (wait_for_sigstop): Avoid TID. (linux_supports_tracefork_flag, linux_tracefork_child, my_waitpid) (linux_test_for_tracefork): New. (linux_lookup_signals): Use thread_db_active and linux_supports_tracefork_flag. (initialize_low): Use thread_db_active and linux_test_for_tracefork. * linux-low.h (get_process_thread): Avoid TID. (struct process_ifo): Move thread_known and tid to the end. Remove sigstop_sent. (linux_attach_lwp, thread_db_init): Update prototypes. * server.h (change_inferior_id): Delete prototype. (add_pid_to_list, pull_pid_from_list): New prototypes. * thread-db.c (thread_db_use_events): New. (find_first_thread): Rename to... (find_one_thread): ...this. Update callers and messages. Do not call fatal. Check thread_db_use_events. Do not call change_inferior_id or new_thread_notify. (maybe_attach_thread): Update. Do not call new_thread_notify. (thread_db_init): Set thread_db_use_events. Check use_events. * utils.c (fatal, warning): Correct message prefix.
2007-10-23 22:05:03 +02:00
{
/* The new child has a pending SIGSTOP. We can't affect it until it
hits the SIGSTOP, but we're already attached. */
ret = my_waitpid (new_pid, &status, __WALL);
* inferiors.c (change_inferior_id): Delete. (add_pid_to_list, pull_pid_from_list): New. * linux-low.c (PTRACE_SETOPTIONS, PTRACE_GETEVENTMSG) (PTRACE_O_TRACESYSGOOD, PTRACE_O_TRACEFORK, PTRACE_O_TRACEVFORK) (PTRACE_O_TRACECLONE, PTRACE_O_TRACEEXEC, PTRACE_O_TRACEVFORKDONE) (PTRACE_O_TRACEEXIT, PTRACE_EVENT_FORK, PTRACE_EVENT_VFORK) (PTRACE_EVENT_CLONE, PTRACE_EVENT_EXEC, PTRACE_EVENT_VFORK_DONE) (PTRACE_EVENT_EXIT, __WALL): Provide default definitions. (stopped_pids, thread_db_active, must_set_ptrace_flags): New variables. (using_threads): Always set to 1. (handle_extended_wait): New. (add_process): Do not set TID. (linux_create_inferior): Set must_set_ptrace_flags. (linux_attach_lwp): Remove TID argument. Do not check using_threads. Use PTRACE_SETOPTIONS. Call new_thread_notify. Update all callers. (linux_thread_alive): Rename TID argument to LWPID. (linux_wait_for_process): Handle unknown processes. Do not use TID. (linux_wait_for_event): Do not use TID or check using_threads. Update call to dead_thread_notify. Call handle_extended_wait. (linux_create_inferior): Use PTRACE_SETOPTIONS. (send_sigstop): Delete sigstop_sent. (wait_for_sigstop): Avoid TID. (linux_supports_tracefork_flag, linux_tracefork_child, my_waitpid) (linux_test_for_tracefork): New. (linux_lookup_signals): Use thread_db_active and linux_supports_tracefork_flag. (initialize_low): Use thread_db_active and linux_test_for_tracefork. * linux-low.h (get_process_thread): Avoid TID. (struct process_ifo): Move thread_known and tid to the end. Remove sigstop_sent. (linux_attach_lwp, thread_db_init): Update prototypes. * server.h (change_inferior_id): Delete prototype. (add_pid_to_list, pull_pid_from_list): New prototypes. * thread-db.c (thread_db_use_events): New. (find_first_thread): Rename to... (find_one_thread): ...this. Update callers and messages. Do not call fatal. Check thread_db_use_events. Do not call change_inferior_id or new_thread_notify. (maybe_attach_thread): Update. Do not call new_thread_notify. (thread_db_init): Set thread_db_use_events. Check use_events. * utils.c (fatal, warning): Correct message prefix.
2007-10-23 22:05:03 +02:00
if (ret == -1)
perror_with_name ("waiting for new child");
else if (ret != new_pid)
warning ("wait returned unexpected PID %d", ret);
else if (!WIFSTOPPED (status))
* inferiors.c (change_inferior_id): Delete. (add_pid_to_list, pull_pid_from_list): New. * linux-low.c (PTRACE_SETOPTIONS, PTRACE_GETEVENTMSG) (PTRACE_O_TRACESYSGOOD, PTRACE_O_TRACEFORK, PTRACE_O_TRACEVFORK) (PTRACE_O_TRACECLONE, PTRACE_O_TRACEEXEC, PTRACE_O_TRACEVFORKDONE) (PTRACE_O_TRACEEXIT, PTRACE_EVENT_FORK, PTRACE_EVENT_VFORK) (PTRACE_EVENT_CLONE, PTRACE_EVENT_EXEC, PTRACE_EVENT_VFORK_DONE) (PTRACE_EVENT_EXIT, __WALL): Provide default definitions. (stopped_pids, thread_db_active, must_set_ptrace_flags): New variables. (using_threads): Always set to 1. (handle_extended_wait): New. (add_process): Do not set TID. (linux_create_inferior): Set must_set_ptrace_flags. (linux_attach_lwp): Remove TID argument. Do not check using_threads. Use PTRACE_SETOPTIONS. Call new_thread_notify. Update all callers. (linux_thread_alive): Rename TID argument to LWPID. (linux_wait_for_process): Handle unknown processes. Do not use TID. (linux_wait_for_event): Do not use TID or check using_threads. Update call to dead_thread_notify. Call handle_extended_wait. (linux_create_inferior): Use PTRACE_SETOPTIONS. (send_sigstop): Delete sigstop_sent. (wait_for_sigstop): Avoid TID. (linux_supports_tracefork_flag, linux_tracefork_child, my_waitpid) (linux_test_for_tracefork): New. (linux_lookup_signals): Use thread_db_active and linux_supports_tracefork_flag. (initialize_low): Use thread_db_active and linux_test_for_tracefork. * linux-low.h (get_process_thread): Avoid TID. (struct process_ifo): Move thread_known and tid to the end. Remove sigstop_sent. (linux_attach_lwp, thread_db_init): Update prototypes. * server.h (change_inferior_id): Delete prototype. (add_pid_to_list, pull_pid_from_list): New prototypes. * thread-db.c (thread_db_use_events): New. (find_first_thread): Rename to... (find_one_thread): ...this. Update callers and messages. Do not call fatal. Check thread_db_use_events. Do not call change_inferior_id or new_thread_notify. (maybe_attach_thread): Update. Do not call new_thread_notify. (thread_db_init): Set thread_db_use_events. Check use_events. * utils.c (fatal, warning): Correct message prefix.
2007-10-23 22:05:03 +02:00
warning ("wait returned unexpected status 0x%x", status);
}
2015-05-12 18:52:45 +02:00
if (event == PTRACE_EVENT_FORK || event == PTRACE_EVENT_VFORK)
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
{
struct process_info *parent_proc;
struct process_info *child_proc;
struct lwp_info *child_lwp;
Initialize last_resume_kind for remote fork child This patch fixes some intermittent test failures in gdb.base/foll-vfork.exp where a vfork child would be (incorrectly) resumed when handling the vfork event. In this case the result was a subsequent event reported to the client side as a SIGTRAP delivered to the as-yet-unknown child thread. The new thread was resumed (incorrectly) in linux-low.c when resume_stopped_resumed_lwps was called from linux_wait_for_event_filtered after the vfork event had been handled in handle_extended_wait. Gdbserver/linux-low.c's add_thread function creates threads with last_resume_kind == resume_continue by default. This field is used by resume_stopped_resumed_lwps to decide whether to perform the resume: static void resume_stopped_resumed_lwps (struct inferior_list_entry *entry) { struct thread_info *thread = (struct thread_info *) entry; struct lwp_info *lp = get_thread_lwp (thread); if (lp->stopped && !lp->status_pending_p && thread->last_resume_kind != resume_stop && thread->last_status.kind == TARGET_WAITKIND_IGNORE) { So the fix is to make sure to set thread->last_resume_kind to resume_stop. Here we do that for new fork children in gdbserver/linux-low.c:handle_extended_wait. In addition, it seemed prudent to initialize lwp_info.status_pending_p for the new fork child. I also rearranged the initialization code so that all of the lwp_info initialization was together, rather than intermixed with thread_info and process_info initialization. Tested native, native-gdbserver, native-extended-gdbserver on x86_64 GNU/Linux. gdb/gdbserver/ * linux-low.c (handle_extended_wait): Initialize thread_info.last_resume_kind for new fork children.
2015-05-28 22:12:01 +02:00
struct thread_info *child_thr;
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
struct target_desc *tdesc;
ptid = ptid_t (new_pid, new_pid, 0);
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
if (debug_threads)
{
debug_printf ("HEW: Got fork event from LWP %ld, "
"new child is %d\n",
Remove ptid_get_lwp This removes ptid_get_lwp in favor of calling the ptid_t::lwp method. gdb/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * common/ptid.c (ptid_get_lwp): Remove. * common/ptid.h (ptid_get_lwp): Don't declare. * aarch64-linux-nat.c: Update. * ada-tasks.c: Update. * aix-thread.c: Update. * amd64-linux-nat.c: Update. * arm-linux-nat.c: Update. * corelow.c: Update. * fbsd-nat.c: Update. * fbsd-tdep.c: Update. * gnu-nat.c: Update. * i386-cygwin-tdep.c: Update. * i386-gnu-nat.c: Update. * i386-linux-nat.c: Update. * ia64-linux-nat.c: Update. * inf-ptrace.c: Update. * infrun.c: Update. * linux-fork.c: Update. * linux-nat.c: Update. * linux-tdep.c: Update. * linux-thread-db.c: Update. * mips-linux-nat.c: Update. * nat/aarch64-linux-hw-point.c: Update. * nat/aarch64-linux.c: Update. * nat/linux-btrace.c: Update. * nat/linux-osdata.c: Update. * nat/linux-procfs.c: Update. * nat/x86-linux-dregs.c: Update. * obsd-nat.c: Update. * ppc-fbsd-nat.c: Update. * ppc-linux-nat.c: Update. * procfs.c: Update. * python/py-infthread.c: Update. * ravenscar-thread.c: Update. * remote.c: Update. * s390-linux-nat.c: Update. * sol-thread.c: Update. * sol2-tdep.c: Update. * spu-linux-nat.c: Update. * x86-linux-nat.c: Update. * xtensa-linux-nat.c: Update. gdb/gdbserver/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * linux-low.c: Update. * linux-mips-low.c: Update. * lynx-low.c: Update. * nto-low.c: Update. * remote-utils.c: Update. * server.c: Update. * spu-low.c: Update. * target.c: Update. * thread-db.c: Update.
2018-06-11 20:10:09 +02:00
ptid_of (event_thr).lwp (),
Remove ptid_get_pid This removes ptid_get_pid in favor of calling the ptid_t::pid method. gdb/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * common/ptid.c (ptid_get_pid): Remove. * common/ptid.h (ptid_get_pid): Don't declare. * aarch64-linux-nat.c: Update. * ada-lang.c: Update. * aix-thread.c: Update. * alpha-bsd-nat.c: Update. * amd64-fbsd-nat.c: Update. * amd64-linux-nat.c: Update. * arm-linux-nat.c: Update. * arm-nbsd-nat.c: Update. * auxv.c: Update. * break-catch-syscall.c: Update. * breakpoint.c: Update. * bsd-uthread.c: Update. * corelow.c: Update. * ctf.c: Update. * darwin-nat.c: Update. * fbsd-nat.c: Update. * fbsd-tdep.c: Update. * gcore.c: Update. * gnu-nat.c: Update. * hppa-nbsd-nat.c: Update. * hppa-obsd-nat.c: Update. * i386-fbsd-nat.c: Update. * ia64-linux-nat.c: Update. * inf-ptrace.c: Update. * infcmd.c: Update. * inferior.c: Update. * inferior.h: Update. * inflow.c: Update. * infrun.c: Update. * linux-fork.c: Update. * linux-nat.c: Update. * linux-tdep.c: Update. * linux-thread-db.c: Update. * m68k-bsd-nat.c: Update. * mi/mi-interp.c: Update. * mi/mi-main.c: Update. * mips-linux-nat.c: Update. * mips-nbsd-nat.c: Update. * mips64-obsd-nat.c: Update. * nat/aarch64-linux-hw-point.c: Update. * nat/aarch64-linux.c: Update. * nat/linux-btrace.c: Update. * nat/linux-osdata.c: Update. * nat/linux-procfs.c: Update. * nat/x86-linux-dregs.c: Update. * nto-procfs.c: Update. * obsd-nat.c: Update. * ppc-linux-nat.c: Update. * ppc-nbsd-nat.c: Update. * ppc-obsd-nat.c: Update. * proc-service.c: Update. * procfs.c: Update. * python/py-inferior.c: Update. * python/py-infthread.c: Update. * ravenscar-thread.c: Update. * record.c: Update. * remote-sim.c: Update. * remote.c: Update. * rs6000-nat.c: Update. * s390-linux-nat.c: Update. * sh-nbsd-nat.c: Update. * sol-thread.c: Update. * sparc-nat.c: Update. * sparc64-tdep.c: Update. * spu-linux-nat.c: Update. * spu-tdep.c: Update. * target-debug.h: Update. * target.c: Update. * thread.c: Update. * tid-parse.c: Update. * tracefile-tfile.c: Update. * vax-bsd-nat.c: Update. * windows-nat.c: Update. * x86-linux-nat.c: Update. * x86-nat.c: Update. gdb/gdbserver/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * linux-low.c: Update. * linux-mips-low.c: Update. * lynx-low.c: Update. * mem-break.c: Update. * nto-low.c: Update. * remote-utils.c: Update. * server.c: Update. * spu-low.c: Update. * target.c: Update. * tracepoint.c: Update.
2018-06-11 20:05:27 +02:00
ptid.pid ());
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
}
/* Add the new process to the tables and clone the breakpoint
lists of the parent. We need to do this even if the new process
will be detached, since we will need the process object and the
breakpoints to remove any breakpoints from memory when we
detach, and the client side will access registers. */
gdbserver/linux-low: turn process/thread addition/deletion ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'new_process', 'delete_process', 'new_thread', 'delete_thread', and 'new_fork' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <add_linux_process> <add_lwp> <delete_lwp> <attach_lwp> <detach_one_lwp> <check_zombie_leaders> <filter_exit_event> <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. * linux-low.cc (delete_lwp): Turn into... (linux_process_target::delete_lwp): ...this. (linux_process_target::low_delete_thread): Define. (linux_add_process): Turn into... (linux_process_target::add_linux_process): ...this. (linux_process_target::low_new_process): Define. (linux_process_target::low_delete_process): Define. (linux_process_target::low_new_fork): Define. (add_lwp): Turn into... (linux_process_target::add_lwp): ...this. (linux_process_target::low_new_thread): Define. (linux_attach_lwp): Turn into... (linux_process_target::attach_lwp): ...this. (linux_detach_one_lwp): Turn into... (linux_process_target::detach_one_lwp): ...this. (linux_detach_lwp_callback): Remove and inline... (linux_process_target::detach): ...here. (check_zombie_leaders): Turn into... (linux_process_target::check_zombie_leaders): ...this. (filter_exit_event): Turn into... (linux_process_target::filter_exit_event): ...this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::create_inferior) (attach_proc_task_lwp_callback) (linux_process_target::attach) (linux_process_target::detach) (linux_process_target::mourn) * thread-db.cc (attach_thread) * linux-x86-low.cc (class x86_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (x86_linux_new_process): Turn into... (x86_target::low_new_process): ...this. (x86_linux_delete_process): Turn into... (x86_target::low_delete_process): ...this. (x86_target::low_new_thread): Define. (x86_target::low_delete_thread): Define. (x86_linux_new_fork): Turn into... (x86_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (aarch64_linux_new_process): Turn into... (aarch64_target::low_new_process): ...this. (aarch64_linux_delete_process): Turn into... (aarch64_target::low_delete_process): ...this. (aarch64_target::low_new_thread): Define. (aarch64_target::low_delete_thread): Define. (aarch64_linux_new_fork): Turn into... (aarch64_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (arm_new_process): Turn into... (arm_target::low_new_process): ...this. (arm_delete_process): Turn into... (arm_target::low_delete_process): ...this. (arm_new_thread): Turn into... (arm_target::low_new_thread): ...this. (arm_delete_thread): Turn into... (arm_target::low_delete_thread): ...this. (arm_new_fork): Turn into... (arm_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (mips_linux_new_process): Turn into... (mips_target::low_new_process): ...this. (mips_linux_delete_process): Turn into... (mips_target::low_delete_process): ...this. (mips_linux_new_thread): Turn into... (mips_target::low_new_thread): ...this. (mips_linux_delete_thread): Turn into... (mips_target::low_delete_thread): ...this. (mips_linux_new_fork): Turn into... (mips_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:28 +02:00
child_proc = add_linux_process (new_pid, 0);
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
gdb_assert (child_proc != NULL);
child_lwp = add_lwp (ptid);
gdb_assert (child_lwp != NULL);
child_lwp->stopped = 1;
Initialize last_resume_kind for remote fork child This patch fixes some intermittent test failures in gdb.base/foll-vfork.exp where a vfork child would be (incorrectly) resumed when handling the vfork event. In this case the result was a subsequent event reported to the client side as a SIGTRAP delivered to the as-yet-unknown child thread. The new thread was resumed (incorrectly) in linux-low.c when resume_stopped_resumed_lwps was called from linux_wait_for_event_filtered after the vfork event had been handled in handle_extended_wait. Gdbserver/linux-low.c's add_thread function creates threads with last_resume_kind == resume_continue by default. This field is used by resume_stopped_resumed_lwps to decide whether to perform the resume: static void resume_stopped_resumed_lwps (struct inferior_list_entry *entry) { struct thread_info *thread = (struct thread_info *) entry; struct lwp_info *lp = get_thread_lwp (thread); if (lp->stopped && !lp->status_pending_p && thread->last_resume_kind != resume_stop && thread->last_status.kind == TARGET_WAITKIND_IGNORE) { So the fix is to make sure to set thread->last_resume_kind to resume_stop. Here we do that for new fork children in gdbserver/linux-low.c:handle_extended_wait. In addition, it seemed prudent to initialize lwp_info.status_pending_p for the new fork child. I also rearranged the initialization code so that all of the lwp_info initialization was together, rather than intermixed with thread_info and process_info initialization. Tested native, native-gdbserver, native-extended-gdbserver on x86_64 GNU/Linux. gdb/gdbserver/ * linux-low.c (handle_extended_wait): Initialize thread_info.last_resume_kind for new fork children.
2015-05-28 22:12:01 +02:00
child_lwp->must_set_ptrace_flags = 1;
child_lwp->status_pending_p = 0;
child_thr = get_lwp_thread (child_lwp);
child_thr->last_resume_kind = resume_stop;
remote follow fork and spurious child stops in non-stop mode Running gdb.threads/fork-plus-threads.exp against gdbserver in extended-remote mode, even though the test passes, we still see broken behavior: (gdb) PASS: gdb.threads/fork-plus-threads.exp: set detach-on-fork off continue & Continuing. (gdb) PASS: gdb.threads/fork-plus-threads.exp: continue & [New Thread 28092.28092] [Thread 28092.28092] #2 stopped. [New Thread 28094.28094] [Inferior 2 (process 28092) exited normally] [New Thread 28094.28105] [New Thread 28094.28109] ... [Thread 28174.28174] #18 stopped. [New Thread 28185.28185] [Inferior 10 (process 28174) exited normally] [New Thread 28185.28196] [Thread 28185.28185] #20 stopped. Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. [Inferior 11 (process 28185) exited normally] [Inferior 1 (process 28091) exited normally] PASS: gdb.threads/fork-plus-threads.exp: reached breakpoint info threads No threads. (gdb) PASS: gdb.threads/fork-plus-threads.exp: no threads left info inferiors Num Description Executable * 1 <null> /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/fork-plus-threads (gdb) PASS: gdb.threads/fork-plus-threads.exp: only inferior 1 left All the "[Thread FOO] #NN stopped." above are bogus, as well as the "Cannot remove breakpoints because program is no longer writable.", which is a consequence. The problem is that when we intercept a fork event, we should report the event for the parent, only, and leave the child stopped, but not report its stop event. GDB later decides whether to follow the parent or the child. But because handle_extended_wait does not set the child's last_status.kind to TARGET_WAITKIND_STOPPED, a stop_all_threads/unstop_all_lwps sequence (e.g., from trying to access memory) by mistake ends up queueing a SIGSTOP on the child, resuming it, and then when that SIGSTOP is intercepted, because the LWP has last_resume_kind set to resume_stop, gdbserver reports the stop to GDB, as GDB_SIGNAL_0: ... >>>> entering unstop_all_lwps unstopping all lwps proceed_one_lwp: lwp 1600 client wants LWP to remain 1600 stopped proceed_one_lwp: lwp 1828 Client wants LWP 1828 to stop. Making sure it has a SIGSTOP pending ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Sending sigstop to lwp 1828 pc is 0x3615ebc7cc Resuming lwp 1828 (continue, signal 0, stop expected) continue from pc 0x3615ebc7cc unstop_all_lwps done sigchld_handler <<<< exiting unstop_all_lwps handling possible target event >>>> entering linux_wait_1 linux_wait_1: [<all threads>] my_waitpid (-1, 0x40000001) my_waitpid (-1, 0x1): status(137f), 1828 LWFE: waitpid(-1, ...) returned 1828, ERRNO-OK LLW: waitpid 1828 received Stopped (signal) (stopped) pc is 0x3615ebc7cc Expected stop. LLW: resume_stop SIGSTOP caught for LWP 1828.1828. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... linux_wait_1 ret = LWP 1828.1828, 1, 0 <<<< exiting linux_wait_1 Writing resume reply for LWP 1828.1828:1 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Tested on x86_64 Fedora 20, extended-remote. gdb/gdbserver/ChangeLog: 2015-07-30 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the child's last reported status to TARGET_WAITKIND_STOPPED.
2015-07-30 19:41:44 +02:00
child_thr->last_status.kind = TARGET_WAITKIND_STOPPED;
gdbserver: Fix non-stop / fork / step-over issues Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html This adds a test that has a multithreaded program have several threads continuously fork, while another thread continuously steps over a breakpoint. This exposes several intertwined issues, which this patch addresses: - When we're stopping and suspending threads, some thread may fork, and we missed setting its suspend count to 1, like we do when a new clone/thread is detected. When we next unsuspend threads, the fork child's suspend count goes below 0, which is bogus and fails an assertion. - If a step-over is cancelled because a signal arrives, but then gdb is not interested in the signal, we pass the signal straight back to the inferior. However, we miss that we need to re-increment the suspend counts of all other threads that had been paused for the step-over. As a result, other threads indefinitely end up stuck stopped. - If a detach request comes in just while gdbserver is handling a step-over (in the test at hand, this is GDB detaching the fork child), gdbserver internal errors in stabilize_thread's helpers, which assert that all thread's suspend counts are 0 (otherwise we wouldn't be able to move threads out of the jump pads). The suspend counts aren't 0 while a step-over is in progress, because all threads but the one stepping past the breakpoint must remain paused until the step-over finishes and the breakpoint can be reinserted. - Occasionally, we see "BAD - reinserting but not stepping." being output (from within linux_resume_one_lwp_throw). That was because GDB pokes memory while gdbserver is busy with a step-over, and that suspends threads, and then re-resumes them with proceed_one_lwp, which missed another reason to tell linux_resume_one_lwp that the thread should be set back to stepping. - In a couple places, we were resuming threads that are meant to be suspended. E.g., when a vCont;c/s request for thread B comes in just while gdbserver is stepping thread A past a breakpoint. The resume for thread B must be deferred until the step-over finishes. - The test runs with both "set detach-on-fork" on and off. When off, it exercises the case of GDB detaching the fork child explicitly. When on, it exercises the case of gdb resuming the child explicitly. In the "off" case, gdb seems to exponentially become slower as new inferiors are created. This is _very_ noticeable as with only 100 inferiors gdb is crawling already, which makes the test take quite a bit to run. For that reason, I've disabled the "off" variant for now. gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * target/waitstatus.h (enum target_stop_reason) <TARGET_STOPPED_BY_SINGLE_STEP>: New value. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the fork child's suspend count if stopping and suspending threads. (check_stopped_by_breakpoint): If stopped by trace, set the LWP's stop reason to TARGET_STOPPED_BY_SINGLE_STEP. (linux_detach): Complete an ongoing step-over. (lwp_suspended_inc, lwp_suspended_decr): New functions. Use throughout. (resume_stopped_resumed_lwps): Don't resume a suspended thread. (linux_wait_1): If passing a signal to the inferior after finishing a step-over, unsuspend and re-resume all lwps. If we see a single-step event but the thread should be continuing, don't pass the trap to gdb. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use internal_error instead of gdb_assert. (enqueue_pending_signal): New function. (check_ptrace_stopped_lwp_gone): Add debug output. (start_step_over): Use internal_error instead of gdb_assert. (complete_ongoing_step_over): New function. (linux_resume_one_thread): Don't resume a suspended thread. (proceed_one_lwp): If the LWP is stepping over a breakpoint, reset it stepping. gdb/testsuite/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * gdb.threads/forking-threads-plus-breakpoint.exp: New file. * gdb.threads/forking-threads-plus-breakpoint.c: New file.
2015-08-06 11:30:18 +02:00
/* If we're suspending all threads, leave this one suspended
[GDBserver] Leave child suspended when step over parent I see the following GDBserver internal error in two cases, gdb/gdbserver/linux-low.c:1922: A problem internal to GDBserver has been detected. unsuspend LWP 17200, suspended=-1 1. step over a breakpoint on fork/vfork syscall instruction, 2. step over a breakpoint on clone syscall instruction and child threads hits a breakpoint, the stack backtrace is #0 internal_error (file=file@entry=0x44c4c0 "gdb/gdbserver/linux-low.c", line=line@entry=1922, fmt=fmt@entry=0x44c7d0 "unsuspend LWP %ld, suspended=%d\n") at gdb/gdbserver/../common/errors.c:51 #1 0x0000000000424014 in lwp_suspended_decr (lwp=<optimised out>, lwp=<optimised out>) at gdb/gdbserver/linux-low.c:1922 #2 0x000000000042403a in unsuspend_one_lwp (entry=<optimised out>, except=0x66e8c0) at gdb/gdbserver/linux-low.c:2885 #3 0x0000000000405f45 in find_inferior (list=<optimised out>, func=func@entry=0x424020 <unsuspend_one_lwp>, arg=arg@entry=0x66e8c0) at gdb/gdbserver/inferiors.c:243 #4 0x00000000004297de in unsuspend_all_lwps (except=0x66e8c0) at gdb/gdbserver/linux-low.c:2895 #5 linux_wait_1 (ptid=..., ourstatus=ourstatus@entry=0x665ec0 <last_status>, target_options=target_options@entry=0) at gdb/gdbserver/linux-low.c:3632 #6 0x000000000042a764 in linux_wait (ptid=..., ourstatus=0x665ec0 <last_status>, target_options=0) at gdb/gdbserver/linux-low.c:3770 #7 0x0000000000411163 in mywait (ptid=..., ourstatus=ourstatus@entry=0x665ec0 <last_status>, options=options@entry=0, connected_wait=connected_wait@entry=1) at gdb/gdbserver/target.c:214 #8 0x000000000040b1f2 in resume (actions=0x66f800, num_actions=1) at gdb/gdbserver/server.c:2757 #9 0x000000000040f660 in handle_v_cont (own_buf=0x66a630 "vCont;c:p45e9.-1") at gdb/gdbserver/server.c:2719 when GDBserver steps over a thread, other threads have been suspended, the "stepping" thread may create new thread, but GDBserver doesn't set it suspend count to 1. When GDBserver unsuspend threads, the child's suspend count goes to -1, and the assert is triggered. In fact, GDBserver has already taken care of suspend count of new thread when GDBserver is suspending all threads except the one GDBserver wants to step over by https://sourceware.org/ml/gdb-patches/2015-07/msg00946.html + /* If we're suspending all threads, leave this one suspended + too. */ + if (stopping_threads == STOPPING_AND_SUSPENDING_THREADS) + { + if (debug_threads) + debug_printf ("HEW: leaving child suspended\n"); + child_lwp->suspended = 1; + } but that is not enough, because new thread is still can be spawned in the thread which is being stepped over. This patch extends the condition that GDBserver set child's suspend count to one if it is suspending threads or stepping over the thread. gdb/gdbserver: 2016-03-03 Yao Qi <yao.qi@linaro.org> PR server/19736 * linux-low.c (handle_extended_wait): Set child suspended if event_lwp->bp_reinsert isn't zero.
2016-03-03 10:17:44 +01:00
too. If the fork/clone parent is stepping over a breakpoint,
all other threads have been suspended already. Leave the
child suspended too. */
if (stopping_threads == STOPPING_AND_SUSPENDING_THREADS
|| event_lwp->bp_reinsert != 0)
gdbserver: Fix non-stop / fork / step-over issues Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html This adds a test that has a multithreaded program have several threads continuously fork, while another thread continuously steps over a breakpoint. This exposes several intertwined issues, which this patch addresses: - When we're stopping and suspending threads, some thread may fork, and we missed setting its suspend count to 1, like we do when a new clone/thread is detected. When we next unsuspend threads, the fork child's suspend count goes below 0, which is bogus and fails an assertion. - If a step-over is cancelled because a signal arrives, but then gdb is not interested in the signal, we pass the signal straight back to the inferior. However, we miss that we need to re-increment the suspend counts of all other threads that had been paused for the step-over. As a result, other threads indefinitely end up stuck stopped. - If a detach request comes in just while gdbserver is handling a step-over (in the test at hand, this is GDB detaching the fork child), gdbserver internal errors in stabilize_thread's helpers, which assert that all thread's suspend counts are 0 (otherwise we wouldn't be able to move threads out of the jump pads). The suspend counts aren't 0 while a step-over is in progress, because all threads but the one stepping past the breakpoint must remain paused until the step-over finishes and the breakpoint can be reinserted. - Occasionally, we see "BAD - reinserting but not stepping." being output (from within linux_resume_one_lwp_throw). That was because GDB pokes memory while gdbserver is busy with a step-over, and that suspends threads, and then re-resumes them with proceed_one_lwp, which missed another reason to tell linux_resume_one_lwp that the thread should be set back to stepping. - In a couple places, we were resuming threads that are meant to be suspended. E.g., when a vCont;c/s request for thread B comes in just while gdbserver is stepping thread A past a breakpoint. The resume for thread B must be deferred until the step-over finishes. - The test runs with both "set detach-on-fork" on and off. When off, it exercises the case of GDB detaching the fork child explicitly. When on, it exercises the case of gdb resuming the child explicitly. In the "off" case, gdb seems to exponentially become slower as new inferiors are created. This is _very_ noticeable as with only 100 inferiors gdb is crawling already, which makes the test take quite a bit to run. For that reason, I've disabled the "off" variant for now. gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * target/waitstatus.h (enum target_stop_reason) <TARGET_STOPPED_BY_SINGLE_STEP>: New value. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the fork child's suspend count if stopping and suspending threads. (check_stopped_by_breakpoint): If stopped by trace, set the LWP's stop reason to TARGET_STOPPED_BY_SINGLE_STEP. (linux_detach): Complete an ongoing step-over. (lwp_suspended_inc, lwp_suspended_decr): New functions. Use throughout. (resume_stopped_resumed_lwps): Don't resume a suspended thread. (linux_wait_1): If passing a signal to the inferior after finishing a step-over, unsuspend and re-resume all lwps. If we see a single-step event but the thread should be continuing, don't pass the trap to gdb. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use internal_error instead of gdb_assert. (enqueue_pending_signal): New function. (check_ptrace_stopped_lwp_gone): Add debug output. (start_step_over): Use internal_error instead of gdb_assert. (complete_ongoing_step_over): New function. (linux_resume_one_thread): Don't resume a suspended thread. (proceed_one_lwp): If the LWP is stepping over a breakpoint, reset it stepping. gdb/testsuite/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * gdb.threads/forking-threads-plus-breakpoint.exp: New file. * gdb.threads/forking-threads-plus-breakpoint.c: New file.
2015-08-06 11:30:18 +02:00
{
if (debug_threads)
debug_printf ("HEW: leaving child suspended\n");
child_lwp->suspended = 1;
}
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
parent_proc = get_thread_process (event_thr);
child_proc->attached = parent_proc->attached;
Handle reinsert breakpoints for vforked child When a thread is doing step-over with reinsert breakpoint, and the instruction executed is a syscall doing vfork, both parent and child share the memory, so the reinsert breakpoint in the space is visible to both of them. Also, removing the reinsert breakpoints from the child will effectively remove them from the parent. We should carefully manipulate reinsert breakpoints for both processes. What we are doing here is that - uninsert reinsert breakpoints from the parent before cloning the breakpoint list. We use "uninsert" instead of "remove", because we need to "reinsert" them back after vfork is done. In fact, "uninsert" removes them from both child and parent process space. - reinsert breakpoints in parent process are still copied to child's breakpoint list, - remove them from child's breakpoint list as what we did for fork, at this point, reinsert breakpoints are removed from the child and the parent, but they are still tracked by the parent's breakpoint list, - once vfork is done, "reinsert" them back to the parent, gdb/gdbserver: 2016-06-17 Yao Qi <yao.qi@linaro.org> * linux-low.c (handle_extended_wait): Call uninsert_reinsert_breakpoints for the parent process. Remove reinsert breakpoints from the child process. Reinsert them to the parent process when vfork is done. * mem-break.c (uninsert_reinsert_breakpoints): New function. (reinsert_reinsert_breakpoints): New function. * mem-break.h (uninsert_reinsert_breakpoints): Declare (reinsert_reinsert_breakpoints): Declare.
2016-06-17 11:25:13 +02:00
if (event_lwp->bp_reinsert != 0
gdbserver/linux-low: turn 'supports_software_single_step' and 'get_next_pcs' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Remove the 'supports_software_single_step' linux target op and let the concrete linux target define it by overriding the op in process_stratum_target. Turn the 'get_next_pcs' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <supports_software_single_step>: Remove. <low_get_next_pcs>: Declare. * linux-low.cc (can_software_single_step): Remove. (linux_process_target::low_get_next_pcs): Define. (linux_process_target::supports_software_single_step): Remove. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::wait_1) (linux_process_target::install_software_single_step_breakpoints) (linux_process_target::single_step) (linux_process_target::thread_needs_step_over) (linux_process_target::proceed_one_lwp) (linux_process_target::supports_range_stepping) * linux-x86-low.cc (the_low_target): Remove the op field. * linux-aarch64-low.cc (the_low_target): Ditto. * linux-bfin-low.cc (the_low_target): Ditto. * linux-cris-low.cc (the_low_target): Ditto. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-mips-low.cc (the_low_target): Ditto. * linux-nios2-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-riscv-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-sparc-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto. * linux-arm-low.cc (class arm_target) <low_get_next_pcs> <supports_software_single_step>: Declare. (arm_target::supports_software_single_step): Define. (arm_gdbserver_get_next_pcs): Turn into... (arm_target::low_get_next_pcs): ...this. (the_low_target): Remove the op field.
2020-04-02 15:11:26 +02:00
&& supports_software_single_step ()
Handle reinsert breakpoints for vforked child When a thread is doing step-over with reinsert breakpoint, and the instruction executed is a syscall doing vfork, both parent and child share the memory, so the reinsert breakpoint in the space is visible to both of them. Also, removing the reinsert breakpoints from the child will effectively remove them from the parent. We should carefully manipulate reinsert breakpoints for both processes. What we are doing here is that - uninsert reinsert breakpoints from the parent before cloning the breakpoint list. We use "uninsert" instead of "remove", because we need to "reinsert" them back after vfork is done. In fact, "uninsert" removes them from both child and parent process space. - reinsert breakpoints in parent process are still copied to child's breakpoint list, - remove them from child's breakpoint list as what we did for fork, at this point, reinsert breakpoints are removed from the child and the parent, but they are still tracked by the parent's breakpoint list, - once vfork is done, "reinsert" them back to the parent, gdb/gdbserver: 2016-06-17 Yao Qi <yao.qi@linaro.org> * linux-low.c (handle_extended_wait): Call uninsert_reinsert_breakpoints for the parent process. Remove reinsert breakpoints from the child process. Reinsert them to the parent process when vfork is done. * mem-break.c (uninsert_reinsert_breakpoints): New function. (reinsert_reinsert_breakpoints): New function. * mem-break.h (uninsert_reinsert_breakpoints): Declare (reinsert_reinsert_breakpoints): Declare.
2016-06-17 11:25:13 +02:00
&& event == PTRACE_EVENT_VFORK)
{
/* If we leave single-step breakpoints there, child will
hit it, so uninsert single-step breakpoints from parent
Handle reinsert breakpoints for vforked child When a thread is doing step-over with reinsert breakpoint, and the instruction executed is a syscall doing vfork, both parent and child share the memory, so the reinsert breakpoint in the space is visible to both of them. Also, removing the reinsert breakpoints from the child will effectively remove them from the parent. We should carefully manipulate reinsert breakpoints for both processes. What we are doing here is that - uninsert reinsert breakpoints from the parent before cloning the breakpoint list. We use "uninsert" instead of "remove", because we need to "reinsert" them back after vfork is done. In fact, "uninsert" removes them from both child and parent process space. - reinsert breakpoints in parent process are still copied to child's breakpoint list, - remove them from child's breakpoint list as what we did for fork, at this point, reinsert breakpoints are removed from the child and the parent, but they are still tracked by the parent's breakpoint list, - once vfork is done, "reinsert" them back to the parent, gdb/gdbserver: 2016-06-17 Yao Qi <yao.qi@linaro.org> * linux-low.c (handle_extended_wait): Call uninsert_reinsert_breakpoints for the parent process. Remove reinsert breakpoints from the child process. Reinsert them to the parent process when vfork is done. * mem-break.c (uninsert_reinsert_breakpoints): New function. (reinsert_reinsert_breakpoints): New function. * mem-break.h (uninsert_reinsert_breakpoints): Declare (reinsert_reinsert_breakpoints): Declare.
2016-06-17 11:25:13 +02:00
(and child). Once vfork child is done, reinsert
them back to parent. */
uninsert_single_step_breakpoints (event_thr);
Handle reinsert breakpoints for vforked child When a thread is doing step-over with reinsert breakpoint, and the instruction executed is a syscall doing vfork, both parent and child share the memory, so the reinsert breakpoint in the space is visible to both of them. Also, removing the reinsert breakpoints from the child will effectively remove them from the parent. We should carefully manipulate reinsert breakpoints for both processes. What we are doing here is that - uninsert reinsert breakpoints from the parent before cloning the breakpoint list. We use "uninsert" instead of "remove", because we need to "reinsert" them back after vfork is done. In fact, "uninsert" removes them from both child and parent process space. - reinsert breakpoints in parent process are still copied to child's breakpoint list, - remove them from child's breakpoint list as what we did for fork, at this point, reinsert breakpoints are removed from the child and the parent, but they are still tracked by the parent's breakpoint list, - once vfork is done, "reinsert" them back to the parent, gdb/gdbserver: 2016-06-17 Yao Qi <yao.qi@linaro.org> * linux-low.c (handle_extended_wait): Call uninsert_reinsert_breakpoints for the parent process. Remove reinsert breakpoints from the child process. Reinsert them to the parent process when vfork is done. * mem-break.c (uninsert_reinsert_breakpoints): New function. (reinsert_reinsert_breakpoints): New function. * mem-break.h (uninsert_reinsert_breakpoints): Declare (reinsert_reinsert_breakpoints): Declare.
2016-06-17 11:25:13 +02:00
}
clone_all_breakpoints (child_thr, event_thr);
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
tdesc = allocate_target_description ();
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
copy_target_description (tdesc, parent_proc->tdesc);
child_proc->tdesc = tdesc;
Arch-specific remote follow fork This patch implements the architecture-specific pieces of follow-fork for remote and extended-remote Linux targets, which in the current implementation copyies the parent's debug register state into the new child's data structures. This is required for x86, arm, aarch64, and mips. This follows the native implementation as closely as possible by implementing a new linux_target_ops function 'new_fork', which is analogous to 'linux_nat_new_fork' in linux-nat.c. In gdbserver, the debug registers are stored in the process list, instead of an architecture-specific list, so the function arguments are process_info pointers instead of an lwp_info and a pid as in the native implementation. In the MIPS implementation the debug register mirror is stored differently from x86, ARM, and aarch64, so instead of doing a simple structure assignment I had to clone the list of watchpoint structures. Tested using gdb.threads/watchpoint-fork.exp on x86, and ran manual tests on a MIPS board and an ARM board. Aarch64 hasn't been tested. gdb/gdbserver/ChangeLog: * linux-aarch64-low.c (aarch64_linux_new_fork): New function. (the_low_target) <new_fork>: Initialize new member. * linux-arm-low.c (arm_new_fork): New function. (the_low_target) <new_fork>: Initialize new member. * linux-low.c (handle_extended_wait): Call new target function new_fork. * linux-low.h (struct linux_target_ops) <new_fork>: New member. * linux-mips-low.c (mips_add_watchpoint): New function extracted from mips_insert_point. (the_low_target) <new_fork>: Initialize new member. (mips_linux_new_fork): New function. (mips_insert_point): Call mips_add_watchpoint. * linux-x86-low.c (x86_linux_new_fork): New function. (the_low_target) <new_fork>: Initialize new member.
2015-05-12 18:52:44 +02:00
/* Clone arch-specific process data. */
gdbserver/linux-low: turn process/thread addition/deletion ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'new_process', 'delete_process', 'new_thread', 'delete_thread', and 'new_fork' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <add_linux_process> <add_lwp> <delete_lwp> <attach_lwp> <detach_one_lwp> <check_zombie_leaders> <filter_exit_event> <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. * linux-low.cc (delete_lwp): Turn into... (linux_process_target::delete_lwp): ...this. (linux_process_target::low_delete_thread): Define. (linux_add_process): Turn into... (linux_process_target::add_linux_process): ...this. (linux_process_target::low_new_process): Define. (linux_process_target::low_delete_process): Define. (linux_process_target::low_new_fork): Define. (add_lwp): Turn into... (linux_process_target::add_lwp): ...this. (linux_process_target::low_new_thread): Define. (linux_attach_lwp): Turn into... (linux_process_target::attach_lwp): ...this. (linux_detach_one_lwp): Turn into... (linux_process_target::detach_one_lwp): ...this. (linux_detach_lwp_callback): Remove and inline... (linux_process_target::detach): ...here. (check_zombie_leaders): Turn into... (linux_process_target::check_zombie_leaders): ...this. (filter_exit_event): Turn into... (linux_process_target::filter_exit_event): ...this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::create_inferior) (attach_proc_task_lwp_callback) (linux_process_target::attach) (linux_process_target::detach) (linux_process_target::mourn) * thread-db.cc (attach_thread) * linux-x86-low.cc (class x86_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (x86_linux_new_process): Turn into... (x86_target::low_new_process): ...this. (x86_linux_delete_process): Turn into... (x86_target::low_delete_process): ...this. (x86_target::low_new_thread): Define. (x86_target::low_delete_thread): Define. (x86_linux_new_fork): Turn into... (x86_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (aarch64_linux_new_process): Turn into... (aarch64_target::low_new_process): ...this. (aarch64_linux_delete_process): Turn into... (aarch64_target::low_delete_process): ...this. (aarch64_target::low_new_thread): Define. (aarch64_target::low_delete_thread): Define. (aarch64_linux_new_fork): Turn into... (aarch64_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (arm_new_process): Turn into... (arm_target::low_new_process): ...this. (arm_delete_process): Turn into... (arm_target::low_delete_process): ...this. (arm_new_thread): Turn into... (arm_target::low_new_thread): ...this. (arm_delete_thread): Turn into... (arm_target::low_delete_thread): ...this. (arm_new_fork): Turn into... (arm_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (mips_linux_new_process): Turn into... (mips_target::low_new_process): ...this. (mips_linux_delete_process): Turn into... (mips_target::low_delete_process): ...this. (mips_linux_new_thread): Turn into... (mips_target::low_new_thread): ...this. (mips_linux_delete_thread): Turn into... (mips_target::low_delete_thread): ...this. (mips_linux_new_fork): Turn into... (mips_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:28 +02:00
low_new_fork (parent_proc, child_proc);
Arch-specific remote follow fork This patch implements the architecture-specific pieces of follow-fork for remote and extended-remote Linux targets, which in the current implementation copyies the parent's debug register state into the new child's data structures. This is required for x86, arm, aarch64, and mips. This follows the native implementation as closely as possible by implementing a new linux_target_ops function 'new_fork', which is analogous to 'linux_nat_new_fork' in linux-nat.c. In gdbserver, the debug registers are stored in the process list, instead of an architecture-specific list, so the function arguments are process_info pointers instead of an lwp_info and a pid as in the native implementation. In the MIPS implementation the debug register mirror is stored differently from x86, ARM, and aarch64, so instead of doing a simple structure assignment I had to clone the list of watchpoint structures. Tested using gdb.threads/watchpoint-fork.exp on x86, and ran manual tests on a MIPS board and an ARM board. Aarch64 hasn't been tested. gdb/gdbserver/ChangeLog: * linux-aarch64-low.c (aarch64_linux_new_fork): New function. (the_low_target) <new_fork>: Initialize new member. * linux-arm-low.c (arm_new_fork): New function. (the_low_target) <new_fork>: Initialize new member. * linux-low.c (handle_extended_wait): Call new target function new_fork. * linux-low.h (struct linux_target_ops) <new_fork>: New member. * linux-mips-low.c (mips_add_watchpoint): New function extracted from mips_insert_point. (the_low_target) <new_fork>: Initialize new member. (mips_linux_new_fork): New function. (mips_insert_point): Call mips_add_watchpoint. * linux-x86-low.c (x86_linux_new_fork): New function. (the_low_target) <new_fork>: Initialize new member.
2015-05-12 18:52:44 +02:00
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
/* Save fork info in the parent thread. */
2015-05-12 18:52:45 +02:00
if (event == PTRACE_EVENT_FORK)
event_lwp->waitstatus.kind = TARGET_WAITKIND_FORKED;
else if (event == PTRACE_EVENT_VFORK)
event_lwp->waitstatus.kind = TARGET_WAITKIND_VFORKED;
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
event_lwp->waitstatus.value.related_pid = ptid;
2015-05-12 18:52:45 +02:00
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
/* The status_pending field contains bits denoting the
extended event, so when the pending event is handled,
the handler will look at lwp->waitstatus. */
event_lwp->status_pending_p = 1;
event_lwp->status_pending = wstat;
gdbserver: Leave already-vCont-resumed threads as they were Currently GDB never sends more than one action per vCont packet, when connected in non-stop mode. A follow up patch will change that, and it exposed a gdbserver problem with the vCont handling. For example, this in non-stop mode: => vCont;s:p1.1;c <= OK Should be equivalent to: => vCont;s:p1.1 <= OK => vCont;c <= OK But gdbserver currently doesn't handle this. In the latter case, "vCont;c" makes gdbserver clobber the previous step request. This patch fixes that. Note the server side must ignore resume actions for the thread that has a pending %Stopped notification (and any other threads with events pending), until GDB acks the notification with vStopped. Otherwise, e.g., the following case is mishandled: #1 => g (or any other packet) #2 <= [registers] #3 <= %Stopped T05 thread:p1.2 #4 => vCont s:p1.1;c #5 <= OK Above, the server must not resume thread p1.2 when it processes the vCont. GDB can't know that p1.2 stopped until it acks the %Stopped notification. (Otherwise it wouldn't send a default "c" action.) (The vCont documentation already specifies this.) Finally, special care must also be given to handling fork/vfork events. A (v)fork event actually tells us that two processes stopped -- the parent and the child. Until we follow the fork, we must not resume the child. Therefore, if we have a pending fork follow, we must not send a global wildcard resume action (vCont;c). We can still send process-wide wildcards though. (The comments above will be added as code comments to gdb in a follow up patch.) gdb/gdbserver/ChangeLog: 2016-10-26 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Link parent/child fork threads. (linux_wait_1): Unlink them. (linux_set_resume_request): Ignore resume requests for already-resumed and unhandled fork child threads. * linux-low.h (struct lwp_info) <fork_relative>: New field. * server.c (in_queued_stop_replies_ptid, in_queued_stop_replies): New functions. (handle_v_requests) <vCont>: Don't call require_running. * server.h (in_queued_stop_replies): New declaration.
2016-10-26 17:17:25 +02:00
/* Link the threads until the parent event is passed on to
higher layers. */
event_lwp->fork_relative = child_lwp;
child_lwp->fork_relative = event_lwp;
/* If the parent thread is doing step-over with single-step
breakpoints, the list of single-step breakpoints are cloned
Handle reinsert breakpoints for vforked child When a thread is doing step-over with reinsert breakpoint, and the instruction executed is a syscall doing vfork, both parent and child share the memory, so the reinsert breakpoint in the space is visible to both of them. Also, removing the reinsert breakpoints from the child will effectively remove them from the parent. We should carefully manipulate reinsert breakpoints for both processes. What we are doing here is that - uninsert reinsert breakpoints from the parent before cloning the breakpoint list. We use "uninsert" instead of "remove", because we need to "reinsert" them back after vfork is done. In fact, "uninsert" removes them from both child and parent process space. - reinsert breakpoints in parent process are still copied to child's breakpoint list, - remove them from child's breakpoint list as what we did for fork, at this point, reinsert breakpoints are removed from the child and the parent, but they are still tracked by the parent's breakpoint list, - once vfork is done, "reinsert" them back to the parent, gdb/gdbserver: 2016-06-17 Yao Qi <yao.qi@linaro.org> * linux-low.c (handle_extended_wait): Call uninsert_reinsert_breakpoints for the parent process. Remove reinsert breakpoints from the child process. Reinsert them to the parent process when vfork is done. * mem-break.c (uninsert_reinsert_breakpoints): New function. (reinsert_reinsert_breakpoints): New function. * mem-break.h (uninsert_reinsert_breakpoints): Declare (reinsert_reinsert_breakpoints): Declare.
2016-06-17 11:25:13 +02:00
from the parent's. Remove them from the child process.
In case of vfork, we'll reinsert them back once vforked
child is done. */
if (event_lwp->bp_reinsert != 0
gdbserver/linux-low: turn 'supports_software_single_step' and 'get_next_pcs' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Remove the 'supports_software_single_step' linux target op and let the concrete linux target define it by overriding the op in process_stratum_target. Turn the 'get_next_pcs' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <supports_software_single_step>: Remove. <low_get_next_pcs>: Declare. * linux-low.cc (can_software_single_step): Remove. (linux_process_target::low_get_next_pcs): Define. (linux_process_target::supports_software_single_step): Remove. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::wait_1) (linux_process_target::install_software_single_step_breakpoints) (linux_process_target::single_step) (linux_process_target::thread_needs_step_over) (linux_process_target::proceed_one_lwp) (linux_process_target::supports_range_stepping) * linux-x86-low.cc (the_low_target): Remove the op field. * linux-aarch64-low.cc (the_low_target): Ditto. * linux-bfin-low.cc (the_low_target): Ditto. * linux-cris-low.cc (the_low_target): Ditto. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-mips-low.cc (the_low_target): Ditto. * linux-nios2-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-riscv-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-sparc-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto. * linux-arm-low.cc (class arm_target) <low_get_next_pcs> <supports_software_single_step>: Declare. (arm_target::supports_software_single_step): Define. (arm_gdbserver_get_next_pcs): Turn into... (arm_target::low_get_next_pcs): ...this. (the_low_target): Remove the op field.
2020-04-02 15:11:26 +02:00
&& supports_software_single_step ())
{
/* The child process is forked and stopped, so it is safe
to access its memory without stopping all other threads
from other processes. */
delete_single_step_breakpoints (child_thr);
gdb_assert (has_single_step_breakpoints (event_thr));
gdb_assert (!has_single_step_breakpoints (child_thr));
}
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
/* Report the event. */
return 0;
}
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
if (debug_threads)
debug_printf ("HEW: Got clone event "
"from LWP %ld, new child is LWP %ld\n",
lwpid_of (event_thr), new_pid);
ptid = ptid_t (pid_of (event_thr), new_pid, 0);
new_lwp = add_lwp (ptid);
* inferiors.c (change_inferior_id): Delete. (add_pid_to_list, pull_pid_from_list): New. * linux-low.c (PTRACE_SETOPTIONS, PTRACE_GETEVENTMSG) (PTRACE_O_TRACESYSGOOD, PTRACE_O_TRACEFORK, PTRACE_O_TRACEVFORK) (PTRACE_O_TRACECLONE, PTRACE_O_TRACEEXEC, PTRACE_O_TRACEVFORKDONE) (PTRACE_O_TRACEEXIT, PTRACE_EVENT_FORK, PTRACE_EVENT_VFORK) (PTRACE_EVENT_CLONE, PTRACE_EVENT_EXEC, PTRACE_EVENT_VFORK_DONE) (PTRACE_EVENT_EXIT, __WALL): Provide default definitions. (stopped_pids, thread_db_active, must_set_ptrace_flags): New variables. (using_threads): Always set to 1. (handle_extended_wait): New. (add_process): Do not set TID. (linux_create_inferior): Set must_set_ptrace_flags. (linux_attach_lwp): Remove TID argument. Do not check using_threads. Use PTRACE_SETOPTIONS. Call new_thread_notify. Update all callers. (linux_thread_alive): Rename TID argument to LWPID. (linux_wait_for_process): Handle unknown processes. Do not use TID. (linux_wait_for_event): Do not use TID or check using_threads. Update call to dead_thread_notify. Call handle_extended_wait. (linux_create_inferior): Use PTRACE_SETOPTIONS. (send_sigstop): Delete sigstop_sent. (wait_for_sigstop): Avoid TID. (linux_supports_tracefork_flag, linux_tracefork_child, my_waitpid) (linux_test_for_tracefork): New. (linux_lookup_signals): Use thread_db_active and linux_supports_tracefork_flag. (initialize_low): Use thread_db_active and linux_test_for_tracefork. * linux-low.h (get_process_thread): Avoid TID. (struct process_ifo): Move thread_known and tid to the end. Remove sigstop_sent. (linux_attach_lwp, thread_db_init): Update prototypes. * server.h (change_inferior_id): Delete prototype. (add_pid_to_list, pull_pid_from_list): New prototypes. * thread-db.c (thread_db_use_events): New. (find_first_thread): Rename to... (find_one_thread): ...this. Update callers and messages. Do not call fatal. Check thread_db_use_events. Do not call change_inferior_id or new_thread_notify. (maybe_attach_thread): Update. Do not call new_thread_notify. (thread_db_init): Set thread_db_use_events. Check use_events. * utils.c (fatal, warning): Correct message prefix.
2007-10-23 22:05:03 +02:00
/* Either we're going to immediately resume the new thread
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
or leave it stopped. resume_one_lwp is a nop if it
thinks the thread is currently running, so set this first
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
before calling resume_one_lwp. */
new_lwp->stopped = 1;
[GDBserver] Leave child suspended when step over parent I see the following GDBserver internal error in two cases, gdb/gdbserver/linux-low.c:1922: A problem internal to GDBserver has been detected. unsuspend LWP 17200, suspended=-1 1. step over a breakpoint on fork/vfork syscall instruction, 2. step over a breakpoint on clone syscall instruction and child threads hits a breakpoint, the stack backtrace is #0 internal_error (file=file@entry=0x44c4c0 "gdb/gdbserver/linux-low.c", line=line@entry=1922, fmt=fmt@entry=0x44c7d0 "unsuspend LWP %ld, suspended=%d\n") at gdb/gdbserver/../common/errors.c:51 #1 0x0000000000424014 in lwp_suspended_decr (lwp=<optimised out>, lwp=<optimised out>) at gdb/gdbserver/linux-low.c:1922 #2 0x000000000042403a in unsuspend_one_lwp (entry=<optimised out>, except=0x66e8c0) at gdb/gdbserver/linux-low.c:2885 #3 0x0000000000405f45 in find_inferior (list=<optimised out>, func=func@entry=0x424020 <unsuspend_one_lwp>, arg=arg@entry=0x66e8c0) at gdb/gdbserver/inferiors.c:243 #4 0x00000000004297de in unsuspend_all_lwps (except=0x66e8c0) at gdb/gdbserver/linux-low.c:2895 #5 linux_wait_1 (ptid=..., ourstatus=ourstatus@entry=0x665ec0 <last_status>, target_options=target_options@entry=0) at gdb/gdbserver/linux-low.c:3632 #6 0x000000000042a764 in linux_wait (ptid=..., ourstatus=0x665ec0 <last_status>, target_options=0) at gdb/gdbserver/linux-low.c:3770 #7 0x0000000000411163 in mywait (ptid=..., ourstatus=ourstatus@entry=0x665ec0 <last_status>, options=options@entry=0, connected_wait=connected_wait@entry=1) at gdb/gdbserver/target.c:214 #8 0x000000000040b1f2 in resume (actions=0x66f800, num_actions=1) at gdb/gdbserver/server.c:2757 #9 0x000000000040f660 in handle_v_cont (own_buf=0x66a630 "vCont;c:p45e9.-1") at gdb/gdbserver/server.c:2719 when GDBserver steps over a thread, other threads have been suspended, the "stepping" thread may create new thread, but GDBserver doesn't set it suspend count to 1. When GDBserver unsuspend threads, the child's suspend count goes to -1, and the assert is triggered. In fact, GDBserver has already taken care of suspend count of new thread when GDBserver is suspending all threads except the one GDBserver wants to step over by https://sourceware.org/ml/gdb-patches/2015-07/msg00946.html + /* If we're suspending all threads, leave this one suspended + too. */ + if (stopping_threads == STOPPING_AND_SUSPENDING_THREADS) + { + if (debug_threads) + debug_printf ("HEW: leaving child suspended\n"); + child_lwp->suspended = 1; + } but that is not enough, because new thread is still can be spawned in the thread which is being stepped over. This patch extends the condition that GDBserver set child's suspend count to one if it is suspending threads or stepping over the thread. gdb/gdbserver: 2016-03-03 Yao Qi <yao.qi@linaro.org> PR server/19736 * linux-low.c (handle_extended_wait): Set child suspended if event_lwp->bp_reinsert isn't zero.
2016-03-03 10:17:44 +01:00
/* If we're suspending all threads, leave this one suspended
too. If the fork/clone parent is stepping over a breakpoint,
all other threads have been suspended already. Leave the
child suspended too. */
if (stopping_threads == STOPPING_AND_SUSPENDING_THREADS
|| event_lwp->bp_reinsert != 0)
new_lwp->suspended = 1;
/* Normally we will get the pending SIGSTOP. But in some cases
we might get another signal delivered to the group first.
If we do get another signal, be sure not to lose it. */
Linux: don't resume new LWPs until we've pulled all events out of the kernel Since the starvation avoidance series (https://sourceware.org/ml/gdb-patches/2014-12/msg00631.html), both GDB and GDBserver pull all events out of ptrace before deciding which event to process. There's one problem with that though. Because we resume new threads immediately when we see a PTRACE_EVENT_CLONE event, if the program constantly spawns threads fast enough, new threads can spawn threads faster we can pull events out of the kernel, and thus we'd get stuck in an infinite loop, never returning any event to the core to process. I occasionally see this happen with the attach-many-short-lived-threads.exp test against gdbserver. The fix is to delay resuming new threads until we've pulled out all events out of the kernel. On native, we already have the resume_stopped_resumed_lwps function that knows to resume LWPs that are stopped with no event to report to the core. So the patch just adds another use. GDBserver didn't have the equivalent yet, so the patch adds one. Tested on x86_64 Fedora 20, native and gdbserver (remote and extended-remote). gdb/gdbserver/ChangeLog: 2015-02-04 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Don't resume LWPs here. (resume_stopped_resumed_lwps): New function. (linux_wait_for_event_filtered): Use it. gdb/ChangeLog: 2015-02-04 Pedro Alves <palves@redhat.com> * linux-nat.c (handle_extended_wait): Don't resume LWPs here. (wait_lwp): Don't call wait_lwp if linux_handle_extended_wait returns true. (resume_stopped_resumed_lwps): Don't check whether the thread is marked as executing. (linux_nat_wait_1): Use resume_stopped_resumed_lwps.
2015-02-04 19:13:28 +01:00
if (WSTOPSIG (status) != SIGSTOP)
{
Rename "process" to "lwp" throughout. * linux-low.c (all_processes): Rename to... (all_lwps): ... this. (inferior_pid, handle_extended_wait, get_stop_pc): Adjust. (add_process): Rename to ... (add_lwp): ... this. Adjust. (linux_create_inferior): Adjust. (linux_attach_lwp): Adjust. (linux_attach): Adjust. (linux_kill_one_process): Rename to ... (linux_kill_one_lwp): ... this. Adjust. (linux_kill): Adjust. (linux_detach_one_process): Rename to ... (linux_detach_one_lwp): ... this. Adjust. (linux_detach): Adjust. (check_removed_breakpoint): Adjust. (status_pending_p): Adjust. (linux_wait_for_process): Rename to ... (linux_wait_for_lwp): ... this. Adjust. (linux_wait_for_event): Adjust. (send_sigstop): Adjust. (wait_for_sigstop): Adjust. (stop_all_processes): Rename to ... (stop_all_lwps): ... this. (linux_resume_one_process): Rename to ... (linux_resume_one_lwp): ... this. Adjust. (linux_set_resume_request, linux_continue_one_thread) (linux_queue_one_thread, resume_status_pending_p) (usr_store_inferior_registers, regsets_store_inferior_registers) (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Adjust. * linux-low.h (get_process): Rename to ... (get_lwp): ... this. Adjust. (get_thread_process): Rename to ... (get_thread_lwp): ... this. Adjust. (get_process_thread): Rename to ... (get_lwp_thread): ... this. Adjust. (struct process_info): Rename to ... (struct lwp_info): ... this. (all_processes): Rename to ... (all_lwps): ... this. * proc-service.c (ps_lgetregs): Adjust. * thread-db.c (thread_db_create_event, find_one_thread) (maybe_attach_thread, thread_db_get_tls_address): Adjust.
2009-03-17 21:25:35 +01:00
new_lwp->stop_expected = 1;
Linux: don't resume new LWPs until we've pulled all events out of the kernel Since the starvation avoidance series (https://sourceware.org/ml/gdb-patches/2014-12/msg00631.html), both GDB and GDBserver pull all events out of ptrace before deciding which event to process. There's one problem with that though. Because we resume new threads immediately when we see a PTRACE_EVENT_CLONE event, if the program constantly spawns threads fast enough, new threads can spawn threads faster we can pull events out of the kernel, and thus we'd get stuck in an infinite loop, never returning any event to the core to process. I occasionally see this happen with the attach-many-short-lived-threads.exp test against gdbserver. The fix is to delay resuming new threads until we've pulled out all events out of the kernel. On native, we already have the resume_stopped_resumed_lwps function that knows to resume LWPs that are stopped with no event to report to the core. So the patch just adds another use. GDBserver didn't have the equivalent yet, so the patch adds one. Tested on x86_64 Fedora 20, native and gdbserver (remote and extended-remote). gdb/gdbserver/ChangeLog: 2015-02-04 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Don't resume LWPs here. (resume_stopped_resumed_lwps): New function. (linux_wait_for_event_filtered): Use it. gdb/ChangeLog: 2015-02-04 Pedro Alves <palves@redhat.com> * linux-nat.c (handle_extended_wait): Don't resume LWPs here. (wait_lwp): Don't call wait_lwp if linux_handle_extended_wait returns true. (resume_stopped_resumed_lwps): Don't check whether the thread is marked as executing. (linux_nat_wait_1): Use resume_stopped_resumed_lwps.
2015-02-04 19:13:28 +01:00
new_lwp->status_pending_p = 1;
new_lwp->status_pending = status;
}
else if (cs.report_thread_events)
Remote thread create/exit events When testing with "maint set target-non-stop on", a few threading-related tests expose an issue that requires new RSP packets. Say there are 3 threads running, 1-3. If GDB tries to stop thread 1, 2 and 3, and then waits for their stops, but meanwhile say, thread 2 exits, GDB hangs forever waiting for a stop for thread 2 that won't ever happen. This patch fixes the issue by adding support for thread exit events to the protocol. However, we don't want these always enabled, as they're useless most of the time, and would slow down remote debugging. So I made it so that GDB can enable/disable them, and then made gdb do that around the cases that need it, which currently is only infrun.c:stop_all_threads. In turn, if we have thread exit events, then the extra "thread x exited" traffic slows down attach-many-short-lived-threads.exp enough that gdb has trouble keeping up with new threads that are spawned while gdb tries to stop existing ones. To fix that I added support for the counterpart thread created events too. Enabling those when we try to stop threads ensures that new threads never get a chance to themselves start new threads, killing the race. gdb/doc/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): List "set/show remote thread-events" command in configuration table. (Stop Reply Packets): Document "T05 create" stop reason and 'w' stop reply. (General Query Packets): Document QThreadEvents packet. Document QThreadEvents qSupported feature. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. If GDB wants to hear about thread create events, leave the new child's status pending. (linux_low_filter_event): If GDB wants to hear about thread exit events, leave the LWP marked dead and don't delete it. (linux_wait_for_event_filtered): Don't check for thread exit. (filter_exit_event): New function. (linux_wait_1): Use it, when returning an exit event. (linux_resume_one_lwp_throw): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. * remote-utils.c (prepare_resume_reply): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.c (report_thread_events): New global. (handle_general_set): Handle QThreadEvents. (handle_query) <qSupported>: Handle and report QThreadEvents+; (handle_target_event): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.h (report_thread_events): Declare. gdb/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * NEWS (New commands): Mention "set/show remote thread-events" commands. (New remote packets): Mention thread created/exited stop reasons and QThreadEvents packet. * infrun.c (disable_thread_events): New function. (stop_all_threads): Disable/enable thread create/exit events. Handle TARGET_WAITKIND_THREAD_EXITED. (handle_inferior_event_1): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * remote.c (remove_child_of_pending_fork): Also remove threads of threads that have TARGET_WAITKIND_THREAD_EXITED events. (remote_parse_stop_reply): Handle "create" magic register. Handle 'w' stop reply. (initialize_remote): Install remote_thread_events as to_thread_events target hook. (remote_thread_events): New function. * target-delegates.c: Regenerate. * target.c (target_thread_events): New function. * target.h (struct target_ops) <to_thread_events>: New field. (target_thread_events): Declare. * target/waitstatus.c (target_waitstatus_to_string): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * target/waitstatus.h (enum target_waitkind) <TARGET_WAITKIND_THREAD_CREATED, TARGET_WAITKIND_THREAD_EXITED): New values.
2015-11-30 17:05:21 +01:00
{
new_lwp->waitstatus.kind = TARGET_WAITKIND_THREAD_CREATED;
new_lwp->status_pending_p = 1;
new_lwp->status_pending = status;
}
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
#ifdef USE_THREAD_DB
thread_db_notice_clone (event_thr, ptid);
#endif
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
/* Don't report the event. */
return 1;
* inferiors.c (change_inferior_id): Delete. (add_pid_to_list, pull_pid_from_list): New. * linux-low.c (PTRACE_SETOPTIONS, PTRACE_GETEVENTMSG) (PTRACE_O_TRACESYSGOOD, PTRACE_O_TRACEFORK, PTRACE_O_TRACEVFORK) (PTRACE_O_TRACECLONE, PTRACE_O_TRACEEXEC, PTRACE_O_TRACEVFORKDONE) (PTRACE_O_TRACEEXIT, PTRACE_EVENT_FORK, PTRACE_EVENT_VFORK) (PTRACE_EVENT_CLONE, PTRACE_EVENT_EXEC, PTRACE_EVENT_VFORK_DONE) (PTRACE_EVENT_EXIT, __WALL): Provide default definitions. (stopped_pids, thread_db_active, must_set_ptrace_flags): New variables. (using_threads): Always set to 1. (handle_extended_wait): New. (add_process): Do not set TID. (linux_create_inferior): Set must_set_ptrace_flags. (linux_attach_lwp): Remove TID argument. Do not check using_threads. Use PTRACE_SETOPTIONS. Call new_thread_notify. Update all callers. (linux_thread_alive): Rename TID argument to LWPID. (linux_wait_for_process): Handle unknown processes. Do not use TID. (linux_wait_for_event): Do not use TID or check using_threads. Update call to dead_thread_notify. Call handle_extended_wait. (linux_create_inferior): Use PTRACE_SETOPTIONS. (send_sigstop): Delete sigstop_sent. (wait_for_sigstop): Avoid TID. (linux_supports_tracefork_flag, linux_tracefork_child, my_waitpid) (linux_test_for_tracefork): New. (linux_lookup_signals): Use thread_db_active and linux_supports_tracefork_flag. (initialize_low): Use thread_db_active and linux_test_for_tracefork. * linux-low.h (get_process_thread): Avoid TID. (struct process_ifo): Move thread_known and tid to the end. Remove sigstop_sent. (linux_attach_lwp, thread_db_init): Update prototypes. * server.h (change_inferior_id): Delete prototype. (add_pid_to_list, pull_pid_from_list): New prototypes. * thread-db.c (thread_db_use_events): New. (find_first_thread): Rename to... (find_one_thread): ...this. Update callers and messages. Do not call fatal. Check thread_db_use_events. Do not call change_inferior_id or new_thread_notify. (maybe_attach_thread): Update. Do not call new_thread_notify. (thread_db_init): Set thread_db_use_events. Check use_events. * utils.c (fatal, warning): Correct message prefix.
2007-10-23 22:05:03 +02:00
}
2015-05-12 18:52:45 +02:00
else if (event == PTRACE_EVENT_VFORK_DONE)
{
event_lwp->waitstatus.kind = TARGET_WAITKIND_VFORK_DONE;
gdbserver/linux-low: turn 'supports_software_single_step' and 'get_next_pcs' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Remove the 'supports_software_single_step' linux target op and let the concrete linux target define it by overriding the op in process_stratum_target. Turn the 'get_next_pcs' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <supports_software_single_step>: Remove. <low_get_next_pcs>: Declare. * linux-low.cc (can_software_single_step): Remove. (linux_process_target::low_get_next_pcs): Define. (linux_process_target::supports_software_single_step): Remove. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::wait_1) (linux_process_target::install_software_single_step_breakpoints) (linux_process_target::single_step) (linux_process_target::thread_needs_step_over) (linux_process_target::proceed_one_lwp) (linux_process_target::supports_range_stepping) * linux-x86-low.cc (the_low_target): Remove the op field. * linux-aarch64-low.cc (the_low_target): Ditto. * linux-bfin-low.cc (the_low_target): Ditto. * linux-cris-low.cc (the_low_target): Ditto. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-mips-low.cc (the_low_target): Ditto. * linux-nios2-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-riscv-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-sparc-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto. * linux-arm-low.cc (class arm_target) <low_get_next_pcs> <supports_software_single_step>: Declare. (arm_target::supports_software_single_step): Define. (arm_gdbserver_get_next_pcs): Turn into... (arm_target::low_get_next_pcs): ...this. (the_low_target): Remove the op field.
2020-04-02 15:11:26 +02:00
if (event_lwp->bp_reinsert != 0 && supports_software_single_step ())
Handle reinsert breakpoints for vforked child When a thread is doing step-over with reinsert breakpoint, and the instruction executed is a syscall doing vfork, both parent and child share the memory, so the reinsert breakpoint in the space is visible to both of them. Also, removing the reinsert breakpoints from the child will effectively remove them from the parent. We should carefully manipulate reinsert breakpoints for both processes. What we are doing here is that - uninsert reinsert breakpoints from the parent before cloning the breakpoint list. We use "uninsert" instead of "remove", because we need to "reinsert" them back after vfork is done. In fact, "uninsert" removes them from both child and parent process space. - reinsert breakpoints in parent process are still copied to child's breakpoint list, - remove them from child's breakpoint list as what we did for fork, at this point, reinsert breakpoints are removed from the child and the parent, but they are still tracked by the parent's breakpoint list, - once vfork is done, "reinsert" them back to the parent, gdb/gdbserver: 2016-06-17 Yao Qi <yao.qi@linaro.org> * linux-low.c (handle_extended_wait): Call uninsert_reinsert_breakpoints for the parent process. Remove reinsert breakpoints from the child process. Reinsert them to the parent process when vfork is done. * mem-break.c (uninsert_reinsert_breakpoints): New function. (reinsert_reinsert_breakpoints): New function. * mem-break.h (uninsert_reinsert_breakpoints): Declare (reinsert_reinsert_breakpoints): Declare.
2016-06-17 11:25:13 +02:00
{
reinsert_single_step_breakpoints (event_thr);
Handle reinsert breakpoints for vforked child When a thread is doing step-over with reinsert breakpoint, and the instruction executed is a syscall doing vfork, both parent and child share the memory, so the reinsert breakpoint in the space is visible to both of them. Also, removing the reinsert breakpoints from the child will effectively remove them from the parent. We should carefully manipulate reinsert breakpoints for both processes. What we are doing here is that - uninsert reinsert breakpoints from the parent before cloning the breakpoint list. We use "uninsert" instead of "remove", because we need to "reinsert" them back after vfork is done. In fact, "uninsert" removes them from both child and parent process space. - reinsert breakpoints in parent process are still copied to child's breakpoint list, - remove them from child's breakpoint list as what we did for fork, at this point, reinsert breakpoints are removed from the child and the parent, but they are still tracked by the parent's breakpoint list, - once vfork is done, "reinsert" them back to the parent, gdb/gdbserver: 2016-06-17 Yao Qi <yao.qi@linaro.org> * linux-low.c (handle_extended_wait): Call uninsert_reinsert_breakpoints for the parent process. Remove reinsert breakpoints from the child process. Reinsert them to the parent process when vfork is done. * mem-break.c (uninsert_reinsert_breakpoints): New function. (reinsert_reinsert_breakpoints): New function. * mem-break.h (uninsert_reinsert_breakpoints): Declare (reinsert_reinsert_breakpoints): Declare.
2016-06-17 11:25:13 +02:00
gdb_assert (has_single_step_breakpoints (event_thr));
Handle reinsert breakpoints for vforked child When a thread is doing step-over with reinsert breakpoint, and the instruction executed is a syscall doing vfork, both parent and child share the memory, so the reinsert breakpoint in the space is visible to both of them. Also, removing the reinsert breakpoints from the child will effectively remove them from the parent. We should carefully manipulate reinsert breakpoints for both processes. What we are doing here is that - uninsert reinsert breakpoints from the parent before cloning the breakpoint list. We use "uninsert" instead of "remove", because we need to "reinsert" them back after vfork is done. In fact, "uninsert" removes them from both child and parent process space. - reinsert breakpoints in parent process are still copied to child's breakpoint list, - remove them from child's breakpoint list as what we did for fork, at this point, reinsert breakpoints are removed from the child and the parent, but they are still tracked by the parent's breakpoint list, - once vfork is done, "reinsert" them back to the parent, gdb/gdbserver: 2016-06-17 Yao Qi <yao.qi@linaro.org> * linux-low.c (handle_extended_wait): Call uninsert_reinsert_breakpoints for the parent process. Remove reinsert breakpoints from the child process. Reinsert them to the parent process when vfork is done. * mem-break.c (uninsert_reinsert_breakpoints): New function. (reinsert_reinsert_breakpoints): New function. * mem-break.h (uninsert_reinsert_breakpoints): Declare (reinsert_reinsert_breakpoints): Declare.
2016-06-17 11:25:13 +02:00
}
2015-05-12 18:52:45 +02:00
/* Report the event. */
return 0;
}
else if (event == PTRACE_EVENT_EXEC && cs.report_exec_events)
Extended-remote follow-exec This patch implements support for exec events on extended-remote Linux targets. Follow-exec-mode and rerun behave as expected. Catchpoints and test updates are implemented in subsequent patches. This patch was derived from a patch posted last October: https://sourceware.org/ml/gdb-patches/2014-10/msg00877.html. It was originally based on some work done by Luis Machado in 2013. IMPLEMENTATION ---------------- Exec events are enabled via ptrace options. When an exec event is detected by gdbserver, the existing process data, along with all its associated lwp and thread data, is deleted and replaced by data for a new single-threaded process. The new process data is initialized with the appropriate parts of the state of the execing process. This approach takes care of several potential pitfalls, including: * deleting the data for an execing non-leader thread before any wait/sigsuspend occurs * correctly initializing the architecture of the execed process We then report the exec event using a new RSP stop reason, "exec". When GDB receives an "exec" event, it saves the status in the event structure's target_waitstatus field, like what is done for remote fork events. Because the original and execed programs may have different architectures, we skip parsing the section of the stop reply packet that contains register data. The register data will be retrieved later after the inferior's architecture has been set up by infrun.c:follow_exec. At that point the exec event is handled by the existing event handling in GDB. However, a few changes were necessary so that infrun.c:follow_exec could accommodate the remote target. * Where follow-exec-mode "new" is handled, we now call add_inferior_with_spaces instead of add_inferior with separate calls to set up the program and address spaces. The motivation for this is that add_inferior_with_spaces also sets up the initial architecture for the inferior, which is needed later by target_find_description when it calls target_gdbarch. * We call a new target function, target_follow_exec. This function allows us to store the execd_pathname in the inferior, instead of using the static string remote_exec_file from remote.c. The static string didn't work for follow-exec-mode "new", since once you switched to the execed program, the original remote exec-file was lost. The execd_pathname is now stored in the inferior's program space as a REGISTRY field. All of the requisite mechanisms for this are defined in remote.c. gdb/gdbserver/ChangeLog: * linux-low.c (linux_mourn): Static declaration. (linux_arch_setup): Move in front of handle_extended_wait. (linux_arch_setup_thread): New function. (handle_extended_wait): Handle exec events. Call linux_arch_setup_thread. Make event_lwp argument a pointer-to-a-pointer. (check_zombie_leaders): Do not check stopped threads. (linux_low_ptrace_options): Add PTRACE_O_TRACEEXEC. (linux_low_filter_event): Add lwp and thread for exec'ing non-leader thread if leader thread has been deleted. Refactor code into linux_arch_setup_thread and call it. Pass child lwp pointer by reference to handle_extended_wait. (linux_wait_for_event_filtered): Update comment. (linux_wait_1): Prevent clobbering exec event status. (linux_supports_exec_events): New function. (linux_target_ops) <supports_exec_events>: Initialize new member. * lynx-low.c (lynx_target_ops) <supports_exec_events>: Initialize new member. * remote-utils.c (prepare_resume_reply): New stop reason 'exec'. * server.c (report_exec_events): New global variable. (handle_query): Handle qSupported query for exec-events feature. (captured_main): Initialize report_exec_events. * server.h (report_exec_events): Declare new global variable. * target.h (struct target_ops) <supports_exec_events>: New member. (target_supports_exec_events): New macro. * win32-low.c (win32_target_ops) <supports_exec_events>: Initialize new member. gdb/ChangeLog: * infrun.c (follow_exec): Use process-style ptid for exec message. Call add_inferior_with_spaces and target_follow_exec. * nat/linux-ptrace.c (linux_supports_traceexec): New function. * nat/linux-ptrace.h (linux_supports_traceexec): Declare. * remote.c (remote_pspace_data): New static variable. (remote_pspace_data_cleanup): New function. (get_remote_exec_file): New function. (set_remote_exec_file_1): New function. (set_remote_exec_file): New function. (show_remote_exec_file): New function. (remote_exec_file): Delete static variable. (anonymous enum) <PACKET_exec_event_feature> New enumeration constant. (remote_protocol_features): Add entry for exec-events feature. (remote_query_supported): Add client side of qSupported query for exec-events feature. (remote_follow_exec): New function. (remote_parse_stop_reply): Handle 'exec' stop reason. (extended_remote_run, extended_remote_create_inferior): Call get_remote_exec_file and set_remote_exec_file_1. (init_extended_remote_ops) <to_follow_exec>: Initialize new member. (_initialize_remote): Call register_program_space_data_with_cleanup. Call add_packet_config_cmd for remote exec-events feature. Modify call to add_setshow_string_noescape_cmd for exec-file to use new functions set_remote_exec_file and show_remote_exec_file. * target-debug.h, target-delegates.c: Regenerated. * target.c (target_follow_exec): New function. * target.h (struct target_ops) <to_follow_exec>: New member. (target_follow_exec): Declare new function.
2015-09-11 20:06:02 +02:00
{
struct process_info *proc;
std::vector<int> syscalls_to_catch;
Extended-remote follow-exec This patch implements support for exec events on extended-remote Linux targets. Follow-exec-mode and rerun behave as expected. Catchpoints and test updates are implemented in subsequent patches. This patch was derived from a patch posted last October: https://sourceware.org/ml/gdb-patches/2014-10/msg00877.html. It was originally based on some work done by Luis Machado in 2013. IMPLEMENTATION ---------------- Exec events are enabled via ptrace options. When an exec event is detected by gdbserver, the existing process data, along with all its associated lwp and thread data, is deleted and replaced by data for a new single-threaded process. The new process data is initialized with the appropriate parts of the state of the execing process. This approach takes care of several potential pitfalls, including: * deleting the data for an execing non-leader thread before any wait/sigsuspend occurs * correctly initializing the architecture of the execed process We then report the exec event using a new RSP stop reason, "exec". When GDB receives an "exec" event, it saves the status in the event structure's target_waitstatus field, like what is done for remote fork events. Because the original and execed programs may have different architectures, we skip parsing the section of the stop reply packet that contains register data. The register data will be retrieved later after the inferior's architecture has been set up by infrun.c:follow_exec. At that point the exec event is handled by the existing event handling in GDB. However, a few changes were necessary so that infrun.c:follow_exec could accommodate the remote target. * Where follow-exec-mode "new" is handled, we now call add_inferior_with_spaces instead of add_inferior with separate calls to set up the program and address spaces. The motivation for this is that add_inferior_with_spaces also sets up the initial architecture for the inferior, which is needed later by target_find_description when it calls target_gdbarch. * We call a new target function, target_follow_exec. This function allows us to store the execd_pathname in the inferior, instead of using the static string remote_exec_file from remote.c. The static string didn't work for follow-exec-mode "new", since once you switched to the execed program, the original remote exec-file was lost. The execd_pathname is now stored in the inferior's program space as a REGISTRY field. All of the requisite mechanisms for this are defined in remote.c. gdb/gdbserver/ChangeLog: * linux-low.c (linux_mourn): Static declaration. (linux_arch_setup): Move in front of handle_extended_wait. (linux_arch_setup_thread): New function. (handle_extended_wait): Handle exec events. Call linux_arch_setup_thread. Make event_lwp argument a pointer-to-a-pointer. (check_zombie_leaders): Do not check stopped threads. (linux_low_ptrace_options): Add PTRACE_O_TRACEEXEC. (linux_low_filter_event): Add lwp and thread for exec'ing non-leader thread if leader thread has been deleted. Refactor code into linux_arch_setup_thread and call it. Pass child lwp pointer by reference to handle_extended_wait. (linux_wait_for_event_filtered): Update comment. (linux_wait_1): Prevent clobbering exec event status. (linux_supports_exec_events): New function. (linux_target_ops) <supports_exec_events>: Initialize new member. * lynx-low.c (lynx_target_ops) <supports_exec_events>: Initialize new member. * remote-utils.c (prepare_resume_reply): New stop reason 'exec'. * server.c (report_exec_events): New global variable. (handle_query): Handle qSupported query for exec-events feature. (captured_main): Initialize report_exec_events. * server.h (report_exec_events): Declare new global variable. * target.h (struct target_ops) <supports_exec_events>: New member. (target_supports_exec_events): New macro. * win32-low.c (win32_target_ops) <supports_exec_events>: Initialize new member. gdb/ChangeLog: * infrun.c (follow_exec): Use process-style ptid for exec message. Call add_inferior_with_spaces and target_follow_exec. * nat/linux-ptrace.c (linux_supports_traceexec): New function. * nat/linux-ptrace.h (linux_supports_traceexec): Declare. * remote.c (remote_pspace_data): New static variable. (remote_pspace_data_cleanup): New function. (get_remote_exec_file): New function. (set_remote_exec_file_1): New function. (set_remote_exec_file): New function. (show_remote_exec_file): New function. (remote_exec_file): Delete static variable. (anonymous enum) <PACKET_exec_event_feature> New enumeration constant. (remote_protocol_features): Add entry for exec-events feature. (remote_query_supported): Add client side of qSupported query for exec-events feature. (remote_follow_exec): New function. (remote_parse_stop_reply): Handle 'exec' stop reason. (extended_remote_run, extended_remote_create_inferior): Call get_remote_exec_file and set_remote_exec_file_1. (init_extended_remote_ops) <to_follow_exec>: Initialize new member. (_initialize_remote): Call register_program_space_data_with_cleanup. Call add_packet_config_cmd for remote exec-events feature. Modify call to add_setshow_string_noescape_cmd for exec-file to use new functions set_remote_exec_file and show_remote_exec_file. * target-debug.h, target-delegates.c: Regenerated. * target.c (target_follow_exec): New function. * target.h (struct target_ops) <to_follow_exec>: New member. (target_follow_exec): Declare new function.
2015-09-11 20:06:02 +02:00
ptid_t event_ptid;
pid_t event_pid;
if (debug_threads)
{
debug_printf ("HEW: Got exec event from LWP %ld\n",
lwpid_of (event_thr));
}
/* Get the event ptid. */
event_ptid = ptid_of (event_thr);
Remove ptid_get_pid This removes ptid_get_pid in favor of calling the ptid_t::pid method. gdb/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * common/ptid.c (ptid_get_pid): Remove. * common/ptid.h (ptid_get_pid): Don't declare. * aarch64-linux-nat.c: Update. * ada-lang.c: Update. * aix-thread.c: Update. * alpha-bsd-nat.c: Update. * amd64-fbsd-nat.c: Update. * amd64-linux-nat.c: Update. * arm-linux-nat.c: Update. * arm-nbsd-nat.c: Update. * auxv.c: Update. * break-catch-syscall.c: Update. * breakpoint.c: Update. * bsd-uthread.c: Update. * corelow.c: Update. * ctf.c: Update. * darwin-nat.c: Update. * fbsd-nat.c: Update. * fbsd-tdep.c: Update. * gcore.c: Update. * gnu-nat.c: Update. * hppa-nbsd-nat.c: Update. * hppa-obsd-nat.c: Update. * i386-fbsd-nat.c: Update. * ia64-linux-nat.c: Update. * inf-ptrace.c: Update. * infcmd.c: Update. * inferior.c: Update. * inferior.h: Update. * inflow.c: Update. * infrun.c: Update. * linux-fork.c: Update. * linux-nat.c: Update. * linux-tdep.c: Update. * linux-thread-db.c: Update. * m68k-bsd-nat.c: Update. * mi/mi-interp.c: Update. * mi/mi-main.c: Update. * mips-linux-nat.c: Update. * mips-nbsd-nat.c: Update. * mips64-obsd-nat.c: Update. * nat/aarch64-linux-hw-point.c: Update. * nat/aarch64-linux.c: Update. * nat/linux-btrace.c: Update. * nat/linux-osdata.c: Update. * nat/linux-procfs.c: Update. * nat/x86-linux-dregs.c: Update. * nto-procfs.c: Update. * obsd-nat.c: Update. * ppc-linux-nat.c: Update. * ppc-nbsd-nat.c: Update. * ppc-obsd-nat.c: Update. * proc-service.c: Update. * procfs.c: Update. * python/py-inferior.c: Update. * python/py-infthread.c: Update. * ravenscar-thread.c: Update. * record.c: Update. * remote-sim.c: Update. * remote.c: Update. * rs6000-nat.c: Update. * s390-linux-nat.c: Update. * sh-nbsd-nat.c: Update. * sol-thread.c: Update. * sparc-nat.c: Update. * sparc64-tdep.c: Update. * spu-linux-nat.c: Update. * spu-tdep.c: Update. * target-debug.h: Update. * target.c: Update. * thread.c: Update. * tid-parse.c: Update. * tracefile-tfile.c: Update. * vax-bsd-nat.c: Update. * windows-nat.c: Update. * x86-linux-nat.c: Update. * x86-nat.c: Update. gdb/gdbserver/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * linux-low.c: Update. * linux-mips-low.c: Update. * lynx-low.c: Update. * mem-break.c: Update. * nto-low.c: Update. * remote-utils.c: Update. * server.c: Update. * spu-low.c: Update. * target.c: Update. * tracepoint.c: Update.
2018-06-11 20:05:27 +02:00
event_pid = event_ptid.pid ();
Extended-remote follow-exec This patch implements support for exec events on extended-remote Linux targets. Follow-exec-mode and rerun behave as expected. Catchpoints and test updates are implemented in subsequent patches. This patch was derived from a patch posted last October: https://sourceware.org/ml/gdb-patches/2014-10/msg00877.html. It was originally based on some work done by Luis Machado in 2013. IMPLEMENTATION ---------------- Exec events are enabled via ptrace options. When an exec event is detected by gdbserver, the existing process data, along with all its associated lwp and thread data, is deleted and replaced by data for a new single-threaded process. The new process data is initialized with the appropriate parts of the state of the execing process. This approach takes care of several potential pitfalls, including: * deleting the data for an execing non-leader thread before any wait/sigsuspend occurs * correctly initializing the architecture of the execed process We then report the exec event using a new RSP stop reason, "exec". When GDB receives an "exec" event, it saves the status in the event structure's target_waitstatus field, like what is done for remote fork events. Because the original and execed programs may have different architectures, we skip parsing the section of the stop reply packet that contains register data. The register data will be retrieved later after the inferior's architecture has been set up by infrun.c:follow_exec. At that point the exec event is handled by the existing event handling in GDB. However, a few changes were necessary so that infrun.c:follow_exec could accommodate the remote target. * Where follow-exec-mode "new" is handled, we now call add_inferior_with_spaces instead of add_inferior with separate calls to set up the program and address spaces. The motivation for this is that add_inferior_with_spaces also sets up the initial architecture for the inferior, which is needed later by target_find_description when it calls target_gdbarch. * We call a new target function, target_follow_exec. This function allows us to store the execd_pathname in the inferior, instead of using the static string remote_exec_file from remote.c. The static string didn't work for follow-exec-mode "new", since once you switched to the execed program, the original remote exec-file was lost. The execd_pathname is now stored in the inferior's program space as a REGISTRY field. All of the requisite mechanisms for this are defined in remote.c. gdb/gdbserver/ChangeLog: * linux-low.c (linux_mourn): Static declaration. (linux_arch_setup): Move in front of handle_extended_wait. (linux_arch_setup_thread): New function. (handle_extended_wait): Handle exec events. Call linux_arch_setup_thread. Make event_lwp argument a pointer-to-a-pointer. (check_zombie_leaders): Do not check stopped threads. (linux_low_ptrace_options): Add PTRACE_O_TRACEEXEC. (linux_low_filter_event): Add lwp and thread for exec'ing non-leader thread if leader thread has been deleted. Refactor code into linux_arch_setup_thread and call it. Pass child lwp pointer by reference to handle_extended_wait. (linux_wait_for_event_filtered): Update comment. (linux_wait_1): Prevent clobbering exec event status. (linux_supports_exec_events): New function. (linux_target_ops) <supports_exec_events>: Initialize new member. * lynx-low.c (lynx_target_ops) <supports_exec_events>: Initialize new member. * remote-utils.c (prepare_resume_reply): New stop reason 'exec'. * server.c (report_exec_events): New global variable. (handle_query): Handle qSupported query for exec-events feature. (captured_main): Initialize report_exec_events. * server.h (report_exec_events): Declare new global variable. * target.h (struct target_ops) <supports_exec_events>: New member. (target_supports_exec_events): New macro. * win32-low.c (win32_target_ops) <supports_exec_events>: Initialize new member. gdb/ChangeLog: * infrun.c (follow_exec): Use process-style ptid for exec message. Call add_inferior_with_spaces and target_follow_exec. * nat/linux-ptrace.c (linux_supports_traceexec): New function. * nat/linux-ptrace.h (linux_supports_traceexec): Declare. * remote.c (remote_pspace_data): New static variable. (remote_pspace_data_cleanup): New function. (get_remote_exec_file): New function. (set_remote_exec_file_1): New function. (set_remote_exec_file): New function. (show_remote_exec_file): New function. (remote_exec_file): Delete static variable. (anonymous enum) <PACKET_exec_event_feature> New enumeration constant. (remote_protocol_features): Add entry for exec-events feature. (remote_query_supported): Add client side of qSupported query for exec-events feature. (remote_follow_exec): New function. (remote_parse_stop_reply): Handle 'exec' stop reason. (extended_remote_run, extended_remote_create_inferior): Call get_remote_exec_file and set_remote_exec_file_1. (init_extended_remote_ops) <to_follow_exec>: Initialize new member. (_initialize_remote): Call register_program_space_data_with_cleanup. Call add_packet_config_cmd for remote exec-events feature. Modify call to add_setshow_string_noescape_cmd for exec-file to use new functions set_remote_exec_file and show_remote_exec_file. * target-debug.h, target-delegates.c: Regenerated. * target.c (target_follow_exec): New function. * target.h (struct target_ops) <to_follow_exec>: New member. (target_follow_exec): Declare new function.
2015-09-11 20:06:02 +02:00
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
/* Save the syscall list from the execing process. */
Extended-remote follow-exec This patch implements support for exec events on extended-remote Linux targets. Follow-exec-mode and rerun behave as expected. Catchpoints and test updates are implemented in subsequent patches. This patch was derived from a patch posted last October: https://sourceware.org/ml/gdb-patches/2014-10/msg00877.html. It was originally based on some work done by Luis Machado in 2013. IMPLEMENTATION ---------------- Exec events are enabled via ptrace options. When an exec event is detected by gdbserver, the existing process data, along with all its associated lwp and thread data, is deleted and replaced by data for a new single-threaded process. The new process data is initialized with the appropriate parts of the state of the execing process. This approach takes care of several potential pitfalls, including: * deleting the data for an execing non-leader thread before any wait/sigsuspend occurs * correctly initializing the architecture of the execed process We then report the exec event using a new RSP stop reason, "exec". When GDB receives an "exec" event, it saves the status in the event structure's target_waitstatus field, like what is done for remote fork events. Because the original and execed programs may have different architectures, we skip parsing the section of the stop reply packet that contains register data. The register data will be retrieved later after the inferior's architecture has been set up by infrun.c:follow_exec. At that point the exec event is handled by the existing event handling in GDB. However, a few changes were necessary so that infrun.c:follow_exec could accommodate the remote target. * Where follow-exec-mode "new" is handled, we now call add_inferior_with_spaces instead of add_inferior with separate calls to set up the program and address spaces. The motivation for this is that add_inferior_with_spaces also sets up the initial architecture for the inferior, which is needed later by target_find_description when it calls target_gdbarch. * We call a new target function, target_follow_exec. This function allows us to store the execd_pathname in the inferior, instead of using the static string remote_exec_file from remote.c. The static string didn't work for follow-exec-mode "new", since once you switched to the execed program, the original remote exec-file was lost. The execd_pathname is now stored in the inferior's program space as a REGISTRY field. All of the requisite mechanisms for this are defined in remote.c. gdb/gdbserver/ChangeLog: * linux-low.c (linux_mourn): Static declaration. (linux_arch_setup): Move in front of handle_extended_wait. (linux_arch_setup_thread): New function. (handle_extended_wait): Handle exec events. Call linux_arch_setup_thread. Make event_lwp argument a pointer-to-a-pointer. (check_zombie_leaders): Do not check stopped threads. (linux_low_ptrace_options): Add PTRACE_O_TRACEEXEC. (linux_low_filter_event): Add lwp and thread for exec'ing non-leader thread if leader thread has been deleted. Refactor code into linux_arch_setup_thread and call it. Pass child lwp pointer by reference to handle_extended_wait. (linux_wait_for_event_filtered): Update comment. (linux_wait_1): Prevent clobbering exec event status. (linux_supports_exec_events): New function. (linux_target_ops) <supports_exec_events>: Initialize new member. * lynx-low.c (lynx_target_ops) <supports_exec_events>: Initialize new member. * remote-utils.c (prepare_resume_reply): New stop reason 'exec'. * server.c (report_exec_events): New global variable. (handle_query): Handle qSupported query for exec-events feature. (captured_main): Initialize report_exec_events. * server.h (report_exec_events): Declare new global variable. * target.h (struct target_ops) <supports_exec_events>: New member. (target_supports_exec_events): New macro. * win32-low.c (win32_target_ops) <supports_exec_events>: Initialize new member. gdb/ChangeLog: * infrun.c (follow_exec): Use process-style ptid for exec message. Call add_inferior_with_spaces and target_follow_exec. * nat/linux-ptrace.c (linux_supports_traceexec): New function. * nat/linux-ptrace.h (linux_supports_traceexec): Declare. * remote.c (remote_pspace_data): New static variable. (remote_pspace_data_cleanup): New function. (get_remote_exec_file): New function. (set_remote_exec_file_1): New function. (set_remote_exec_file): New function. (show_remote_exec_file): New function. (remote_exec_file): Delete static variable. (anonymous enum) <PACKET_exec_event_feature> New enumeration constant. (remote_protocol_features): Add entry for exec-events feature. (remote_query_supported): Add client side of qSupported query for exec-events feature. (remote_follow_exec): New function. (remote_parse_stop_reply): Handle 'exec' stop reason. (extended_remote_run, extended_remote_create_inferior): Call get_remote_exec_file and set_remote_exec_file_1. (init_extended_remote_ops) <to_follow_exec>: Initialize new member. (_initialize_remote): Call register_program_space_data_with_cleanup. Call add_packet_config_cmd for remote exec-events feature. Modify call to add_setshow_string_noescape_cmd for exec-file to use new functions set_remote_exec_file and show_remote_exec_file. * target-debug.h, target-delegates.c: Regenerated. * target.c (target_follow_exec): New function. * target.h (struct target_ops) <to_follow_exec>: New member. (target_follow_exec): Declare new function.
2015-09-11 20:06:02 +02:00
proc = get_thread_process (event_thr);
syscalls_to_catch = std::move (proc->syscalls_to_catch);
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
/* Delete the execing process and all its threads. */
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
mourn (proc);
Extended-remote follow-exec This patch implements support for exec events on extended-remote Linux targets. Follow-exec-mode and rerun behave as expected. Catchpoints and test updates are implemented in subsequent patches. This patch was derived from a patch posted last October: https://sourceware.org/ml/gdb-patches/2014-10/msg00877.html. It was originally based on some work done by Luis Machado in 2013. IMPLEMENTATION ---------------- Exec events are enabled via ptrace options. When an exec event is detected by gdbserver, the existing process data, along with all its associated lwp and thread data, is deleted and replaced by data for a new single-threaded process. The new process data is initialized with the appropriate parts of the state of the execing process. This approach takes care of several potential pitfalls, including: * deleting the data for an execing non-leader thread before any wait/sigsuspend occurs * correctly initializing the architecture of the execed process We then report the exec event using a new RSP stop reason, "exec". When GDB receives an "exec" event, it saves the status in the event structure's target_waitstatus field, like what is done for remote fork events. Because the original and execed programs may have different architectures, we skip parsing the section of the stop reply packet that contains register data. The register data will be retrieved later after the inferior's architecture has been set up by infrun.c:follow_exec. At that point the exec event is handled by the existing event handling in GDB. However, a few changes were necessary so that infrun.c:follow_exec could accommodate the remote target. * Where follow-exec-mode "new" is handled, we now call add_inferior_with_spaces instead of add_inferior with separate calls to set up the program and address spaces. The motivation for this is that add_inferior_with_spaces also sets up the initial architecture for the inferior, which is needed later by target_find_description when it calls target_gdbarch. * We call a new target function, target_follow_exec. This function allows us to store the execd_pathname in the inferior, instead of using the static string remote_exec_file from remote.c. The static string didn't work for follow-exec-mode "new", since once you switched to the execed program, the original remote exec-file was lost. The execd_pathname is now stored in the inferior's program space as a REGISTRY field. All of the requisite mechanisms for this are defined in remote.c. gdb/gdbserver/ChangeLog: * linux-low.c (linux_mourn): Static declaration. (linux_arch_setup): Move in front of handle_extended_wait. (linux_arch_setup_thread): New function. (handle_extended_wait): Handle exec events. Call linux_arch_setup_thread. Make event_lwp argument a pointer-to-a-pointer. (check_zombie_leaders): Do not check stopped threads. (linux_low_ptrace_options): Add PTRACE_O_TRACEEXEC. (linux_low_filter_event): Add lwp and thread for exec'ing non-leader thread if leader thread has been deleted. Refactor code into linux_arch_setup_thread and call it. Pass child lwp pointer by reference to handle_extended_wait. (linux_wait_for_event_filtered): Update comment. (linux_wait_1): Prevent clobbering exec event status. (linux_supports_exec_events): New function. (linux_target_ops) <supports_exec_events>: Initialize new member. * lynx-low.c (lynx_target_ops) <supports_exec_events>: Initialize new member. * remote-utils.c (prepare_resume_reply): New stop reason 'exec'. * server.c (report_exec_events): New global variable. (handle_query): Handle qSupported query for exec-events feature. (captured_main): Initialize report_exec_events. * server.h (report_exec_events): Declare new global variable. * target.h (struct target_ops) <supports_exec_events>: New member. (target_supports_exec_events): New macro. * win32-low.c (win32_target_ops) <supports_exec_events>: Initialize new member. gdb/ChangeLog: * infrun.c (follow_exec): Use process-style ptid for exec message. Call add_inferior_with_spaces and target_follow_exec. * nat/linux-ptrace.c (linux_supports_traceexec): New function. * nat/linux-ptrace.h (linux_supports_traceexec): Declare. * remote.c (remote_pspace_data): New static variable. (remote_pspace_data_cleanup): New function. (get_remote_exec_file): New function. (set_remote_exec_file_1): New function. (set_remote_exec_file): New function. (show_remote_exec_file): New function. (remote_exec_file): Delete static variable. (anonymous enum) <PACKET_exec_event_feature> New enumeration constant. (remote_protocol_features): Add entry for exec-events feature. (remote_query_supported): Add client side of qSupported query for exec-events feature. (remote_follow_exec): New function. (remote_parse_stop_reply): Handle 'exec' stop reason. (extended_remote_run, extended_remote_create_inferior): Call get_remote_exec_file and set_remote_exec_file_1. (init_extended_remote_ops) <to_follow_exec>: Initialize new member. (_initialize_remote): Call register_program_space_data_with_cleanup. Call add_packet_config_cmd for remote exec-events feature. Modify call to add_setshow_string_noescape_cmd for exec-file to use new functions set_remote_exec_file and show_remote_exec_file. * target-debug.h, target-delegates.c: Regenerated. * target.c (target_follow_exec): New function. * target.h (struct target_ops) <to_follow_exec>: New member. (target_follow_exec): Declare new function.
2015-09-11 20:06:02 +02:00
current_thread = NULL;
/* Create a new process/lwp/thread. */
gdbserver/linux-low: turn process/thread addition/deletion ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'new_process', 'delete_process', 'new_thread', 'delete_thread', and 'new_fork' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <add_linux_process> <add_lwp> <delete_lwp> <attach_lwp> <detach_one_lwp> <check_zombie_leaders> <filter_exit_event> <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. * linux-low.cc (delete_lwp): Turn into... (linux_process_target::delete_lwp): ...this. (linux_process_target::low_delete_thread): Define. (linux_add_process): Turn into... (linux_process_target::add_linux_process): ...this. (linux_process_target::low_new_process): Define. (linux_process_target::low_delete_process): Define. (linux_process_target::low_new_fork): Define. (add_lwp): Turn into... (linux_process_target::add_lwp): ...this. (linux_process_target::low_new_thread): Define. (linux_attach_lwp): Turn into... (linux_process_target::attach_lwp): ...this. (linux_detach_one_lwp): Turn into... (linux_process_target::detach_one_lwp): ...this. (linux_detach_lwp_callback): Remove and inline... (linux_process_target::detach): ...here. (check_zombie_leaders): Turn into... (linux_process_target::check_zombie_leaders): ...this. (filter_exit_event): Turn into... (linux_process_target::filter_exit_event): ...this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::create_inferior) (attach_proc_task_lwp_callback) (linux_process_target::attach) (linux_process_target::detach) (linux_process_target::mourn) * thread-db.cc (attach_thread) * linux-x86-low.cc (class x86_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (x86_linux_new_process): Turn into... (x86_target::low_new_process): ...this. (x86_linux_delete_process): Turn into... (x86_target::low_delete_process): ...this. (x86_target::low_new_thread): Define. (x86_target::low_delete_thread): Define. (x86_linux_new_fork): Turn into... (x86_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (aarch64_linux_new_process): Turn into... (aarch64_target::low_new_process): ...this. (aarch64_linux_delete_process): Turn into... (aarch64_target::low_delete_process): ...this. (aarch64_target::low_new_thread): Define. (aarch64_target::low_delete_thread): Define. (aarch64_linux_new_fork): Turn into... (aarch64_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (arm_new_process): Turn into... (arm_target::low_new_process): ...this. (arm_delete_process): Turn into... (arm_target::low_delete_process): ...this. (arm_new_thread): Turn into... (arm_target::low_new_thread): ...this. (arm_delete_thread): Turn into... (arm_target::low_delete_thread): ...this. (arm_new_fork): Turn into... (arm_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (mips_linux_new_process): Turn into... (mips_target::low_new_process): ...this. (mips_linux_delete_process): Turn into... (mips_target::low_delete_process): ...this. (mips_linux_new_thread): Turn into... (mips_target::low_new_thread): ...this. (mips_linux_delete_thread): Turn into... (mips_target::low_delete_thread): ...this. (mips_linux_new_fork): Turn into... (mips_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:28 +02:00
proc = add_linux_process (event_pid, 0);
Extended-remote follow-exec This patch implements support for exec events on extended-remote Linux targets. Follow-exec-mode and rerun behave as expected. Catchpoints and test updates are implemented in subsequent patches. This patch was derived from a patch posted last October: https://sourceware.org/ml/gdb-patches/2014-10/msg00877.html. It was originally based on some work done by Luis Machado in 2013. IMPLEMENTATION ---------------- Exec events are enabled via ptrace options. When an exec event is detected by gdbserver, the existing process data, along with all its associated lwp and thread data, is deleted and replaced by data for a new single-threaded process. The new process data is initialized with the appropriate parts of the state of the execing process. This approach takes care of several potential pitfalls, including: * deleting the data for an execing non-leader thread before any wait/sigsuspend occurs * correctly initializing the architecture of the execed process We then report the exec event using a new RSP stop reason, "exec". When GDB receives an "exec" event, it saves the status in the event structure's target_waitstatus field, like what is done for remote fork events. Because the original and execed programs may have different architectures, we skip parsing the section of the stop reply packet that contains register data. The register data will be retrieved later after the inferior's architecture has been set up by infrun.c:follow_exec. At that point the exec event is handled by the existing event handling in GDB. However, a few changes were necessary so that infrun.c:follow_exec could accommodate the remote target. * Where follow-exec-mode "new" is handled, we now call add_inferior_with_spaces instead of add_inferior with separate calls to set up the program and address spaces. The motivation for this is that add_inferior_with_spaces also sets up the initial architecture for the inferior, which is needed later by target_find_description when it calls target_gdbarch. * We call a new target function, target_follow_exec. This function allows us to store the execd_pathname in the inferior, instead of using the static string remote_exec_file from remote.c. The static string didn't work for follow-exec-mode "new", since once you switched to the execed program, the original remote exec-file was lost. The execd_pathname is now stored in the inferior's program space as a REGISTRY field. All of the requisite mechanisms for this are defined in remote.c. gdb/gdbserver/ChangeLog: * linux-low.c (linux_mourn): Static declaration. (linux_arch_setup): Move in front of handle_extended_wait. (linux_arch_setup_thread): New function. (handle_extended_wait): Handle exec events. Call linux_arch_setup_thread. Make event_lwp argument a pointer-to-a-pointer. (check_zombie_leaders): Do not check stopped threads. (linux_low_ptrace_options): Add PTRACE_O_TRACEEXEC. (linux_low_filter_event): Add lwp and thread for exec'ing non-leader thread if leader thread has been deleted. Refactor code into linux_arch_setup_thread and call it. Pass child lwp pointer by reference to handle_extended_wait. (linux_wait_for_event_filtered): Update comment. (linux_wait_1): Prevent clobbering exec event status. (linux_supports_exec_events): New function. (linux_target_ops) <supports_exec_events>: Initialize new member. * lynx-low.c (lynx_target_ops) <supports_exec_events>: Initialize new member. * remote-utils.c (prepare_resume_reply): New stop reason 'exec'. * server.c (report_exec_events): New global variable. (handle_query): Handle qSupported query for exec-events feature. (captured_main): Initialize report_exec_events. * server.h (report_exec_events): Declare new global variable. * target.h (struct target_ops) <supports_exec_events>: New member. (target_supports_exec_events): New macro. * win32-low.c (win32_target_ops) <supports_exec_events>: Initialize new member. gdb/ChangeLog: * infrun.c (follow_exec): Use process-style ptid for exec message. Call add_inferior_with_spaces and target_follow_exec. * nat/linux-ptrace.c (linux_supports_traceexec): New function. * nat/linux-ptrace.h (linux_supports_traceexec): Declare. * remote.c (remote_pspace_data): New static variable. (remote_pspace_data_cleanup): New function. (get_remote_exec_file): New function. (set_remote_exec_file_1): New function. (set_remote_exec_file): New function. (show_remote_exec_file): New function. (remote_exec_file): Delete static variable. (anonymous enum) <PACKET_exec_event_feature> New enumeration constant. (remote_protocol_features): Add entry for exec-events feature. (remote_query_supported): Add client side of qSupported query for exec-events feature. (remote_follow_exec): New function. (remote_parse_stop_reply): Handle 'exec' stop reason. (extended_remote_run, extended_remote_create_inferior): Call get_remote_exec_file and set_remote_exec_file_1. (init_extended_remote_ops) <to_follow_exec>: Initialize new member. (_initialize_remote): Call register_program_space_data_with_cleanup. Call add_packet_config_cmd for remote exec-events feature. Modify call to add_setshow_string_noescape_cmd for exec-file to use new functions set_remote_exec_file and show_remote_exec_file. * target-debug.h, target-delegates.c: Regenerated. * target.c (target_follow_exec): New function. * target.h (struct target_ops) <to_follow_exec>: New member. (target_follow_exec): Declare new function.
2015-09-11 20:06:02 +02:00
event_lwp = add_lwp (event_ptid);
event_thr = get_lwp_thread (event_lwp);
gdb_assert (current_thread == event_thr);
gdbserver/linux-low: turn 'arch_setup' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'arch_setup' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops) <arch_setup>: Delete. (class linux_process_target) <arch_setup_thread> <low_arch_setup>: New declarations. * linux-low.cc (linux_arch_setup): Delete. (linux_arch_setup_thread): Turn into... (linux_process_target::arch_setup_thread): ... this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::post_create_inferior) (linux_process_target::filter_event) * linux-x86-low.cc (class x86_target) <low_arch_setup>: New declaration. (x86_linux_update_xmltarget): Turn into... (x86_target::update_xmltarget): ...this. (x86_linux_process_qsupported): Update the call to x86_linux_update_xmltarget. (x86_arch_setup): Turn into ... (x86_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <low_arch_setup>: New declaration. (aarch64_arch_setup): Turn into ... (aarch64_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (class arm_target) <low_arch_setup>: New declaration. (arm_arch_setup): Turn into ... (arm_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-bfin-low.cc (class bfin_target) <low_arch_setup>: New declaration. (bfin_arch_setup): Turn into ... (bfin_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-cris-low.cc (class cris_target) <low_arch_setup>: New declaration. (cris_arch_setup): Turn into ... (cris_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-crisv32-low.cc (class crisv32_target) <low_arch_setup>: New declaration. (crisv32_arch_setup): Turn into ... (crisv32_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-ia64-low.cc (class ia64_target) <low_arch_setup>: New declaration. (ia64_arch_setup): Turn into ... (ia64_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-m32r-low.cc (class m32r_target) <low_arch_setup>: New declaration. (m32r_arch_setup): Turn into ... (m32r_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-m68k-low.cc (class m68k_target) <low_arch_setup>: New declaration. (m68k_arch_setup): Turn into ... (m68k_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-mips-low.cc (class mips_target) <low_arch_setup>: New declaration. (mips_arch_setup): Turn into ... (mips_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-nios2-low.cc (class nios2_target) <low_arch_setup>: New declaration. (nios2_arch_setup): Turn into ... (nios2_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (class ppc_target) <low_arch_setup>: New declaration. (ppc_arch_setup): Turn into ... (ppc_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-riscv-low.cc (class riscv_target) <low_arch_setup>: New declaration. (riscv_arch_setup): Turn into ... (riscv_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-s390-low.cc (class s390_target) <low_arch_setup>: New declaration. (s390_arch_setup): Turn into ... (s390_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-sh-low.cc (class sh_target) <low_arch_setup>: New declaration. (sh_arch_setup): Turn into ... (sh_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-sparc-low.cc (class sparc_target) <low_arch_setup>: New declaration. (sparc_arch_setup): Turn into ... (sparc_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-tic6x-low.cc (class tic6x_target) <low_arch_setup>: New declaration. (tic6x_arch_setup): Turn into ... (tic6x_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-tile-low.cc (class tile_target) <low_arch_setup>: New declaration. (tile_arch_setup): Turn into ... (tile_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-xtensa-low.cc (class xtensa_target) <low_arch_setup>: New declaration. (xtensa_arch_setup): Turn into ... (xtensa_target::low_arch_setup): ...this. (the_low_target): Remove the op field.
2020-04-02 15:11:23 +02:00
arch_setup_thread (event_thr);
Extended-remote follow-exec This patch implements support for exec events on extended-remote Linux targets. Follow-exec-mode and rerun behave as expected. Catchpoints and test updates are implemented in subsequent patches. This patch was derived from a patch posted last October: https://sourceware.org/ml/gdb-patches/2014-10/msg00877.html. It was originally based on some work done by Luis Machado in 2013. IMPLEMENTATION ---------------- Exec events are enabled via ptrace options. When an exec event is detected by gdbserver, the existing process data, along with all its associated lwp and thread data, is deleted and replaced by data for a new single-threaded process. The new process data is initialized with the appropriate parts of the state of the execing process. This approach takes care of several potential pitfalls, including: * deleting the data for an execing non-leader thread before any wait/sigsuspend occurs * correctly initializing the architecture of the execed process We then report the exec event using a new RSP stop reason, "exec". When GDB receives an "exec" event, it saves the status in the event structure's target_waitstatus field, like what is done for remote fork events. Because the original and execed programs may have different architectures, we skip parsing the section of the stop reply packet that contains register data. The register data will be retrieved later after the inferior's architecture has been set up by infrun.c:follow_exec. At that point the exec event is handled by the existing event handling in GDB. However, a few changes were necessary so that infrun.c:follow_exec could accommodate the remote target. * Where follow-exec-mode "new" is handled, we now call add_inferior_with_spaces instead of add_inferior with separate calls to set up the program and address spaces. The motivation for this is that add_inferior_with_spaces also sets up the initial architecture for the inferior, which is needed later by target_find_description when it calls target_gdbarch. * We call a new target function, target_follow_exec. This function allows us to store the execd_pathname in the inferior, instead of using the static string remote_exec_file from remote.c. The static string didn't work for follow-exec-mode "new", since once you switched to the execed program, the original remote exec-file was lost. The execd_pathname is now stored in the inferior's program space as a REGISTRY field. All of the requisite mechanisms for this are defined in remote.c. gdb/gdbserver/ChangeLog: * linux-low.c (linux_mourn): Static declaration. (linux_arch_setup): Move in front of handle_extended_wait. (linux_arch_setup_thread): New function. (handle_extended_wait): Handle exec events. Call linux_arch_setup_thread. Make event_lwp argument a pointer-to-a-pointer. (check_zombie_leaders): Do not check stopped threads. (linux_low_ptrace_options): Add PTRACE_O_TRACEEXEC. (linux_low_filter_event): Add lwp and thread for exec'ing non-leader thread if leader thread has been deleted. Refactor code into linux_arch_setup_thread and call it. Pass child lwp pointer by reference to handle_extended_wait. (linux_wait_for_event_filtered): Update comment. (linux_wait_1): Prevent clobbering exec event status. (linux_supports_exec_events): New function. (linux_target_ops) <supports_exec_events>: Initialize new member. * lynx-low.c (lynx_target_ops) <supports_exec_events>: Initialize new member. * remote-utils.c (prepare_resume_reply): New stop reason 'exec'. * server.c (report_exec_events): New global variable. (handle_query): Handle qSupported query for exec-events feature. (captured_main): Initialize report_exec_events. * server.h (report_exec_events): Declare new global variable. * target.h (struct target_ops) <supports_exec_events>: New member. (target_supports_exec_events): New macro. * win32-low.c (win32_target_ops) <supports_exec_events>: Initialize new member. gdb/ChangeLog: * infrun.c (follow_exec): Use process-style ptid for exec message. Call add_inferior_with_spaces and target_follow_exec. * nat/linux-ptrace.c (linux_supports_traceexec): New function. * nat/linux-ptrace.h (linux_supports_traceexec): Declare. * remote.c (remote_pspace_data): New static variable. (remote_pspace_data_cleanup): New function. (get_remote_exec_file): New function. (set_remote_exec_file_1): New function. (set_remote_exec_file): New function. (show_remote_exec_file): New function. (remote_exec_file): Delete static variable. (anonymous enum) <PACKET_exec_event_feature> New enumeration constant. (remote_protocol_features): Add entry for exec-events feature. (remote_query_supported): Add client side of qSupported query for exec-events feature. (remote_follow_exec): New function. (remote_parse_stop_reply): Handle 'exec' stop reason. (extended_remote_run, extended_remote_create_inferior): Call get_remote_exec_file and set_remote_exec_file_1. (init_extended_remote_ops) <to_follow_exec>: Initialize new member. (_initialize_remote): Call register_program_space_data_with_cleanup. Call add_packet_config_cmd for remote exec-events feature. Modify call to add_setshow_string_noescape_cmd for exec-file to use new functions set_remote_exec_file and show_remote_exec_file. * target-debug.h, target-delegates.c: Regenerated. * target.c (target_follow_exec): New function. * target.h (struct target_ops) <to_follow_exec>: New member. (target_follow_exec): Declare new function.
2015-09-11 20:06:02 +02:00
/* Set the event status. */
event_lwp->waitstatus.kind = TARGET_WAITKIND_EXECD;
event_lwp->waitstatus.value.execd_pathname
= xstrdup (linux_proc_pid_to_exec_file (lwpid_of (event_thr)));
/* Mark the exec status as pending. */
event_lwp->stopped = 1;
event_lwp->status_pending_p = 1;
event_lwp->status_pending = wstat;
event_thr->last_resume_kind = resume_continue;
event_thr->last_status.kind = TARGET_WAITKIND_IGNORE;
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
/* Update syscall state in the new lwp, effectively mid-syscall too. */
event_lwp->syscall_state = TARGET_WAITKIND_SYSCALL_ENTRY;
/* Restore the list to catch. Don't rely on the client, which is free
to avoid sending a new list when the architecture doesn't change.
Also, for ANY_SYSCALL, the architecture doesn't really matter. */
proc->syscalls_to_catch = std::move (syscalls_to_catch);
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
Extended-remote follow-exec This patch implements support for exec events on extended-remote Linux targets. Follow-exec-mode and rerun behave as expected. Catchpoints and test updates are implemented in subsequent patches. This patch was derived from a patch posted last October: https://sourceware.org/ml/gdb-patches/2014-10/msg00877.html. It was originally based on some work done by Luis Machado in 2013. IMPLEMENTATION ---------------- Exec events are enabled via ptrace options. When an exec event is detected by gdbserver, the existing process data, along with all its associated lwp and thread data, is deleted and replaced by data for a new single-threaded process. The new process data is initialized with the appropriate parts of the state of the execing process. This approach takes care of several potential pitfalls, including: * deleting the data for an execing non-leader thread before any wait/sigsuspend occurs * correctly initializing the architecture of the execed process We then report the exec event using a new RSP stop reason, "exec". When GDB receives an "exec" event, it saves the status in the event structure's target_waitstatus field, like what is done for remote fork events. Because the original and execed programs may have different architectures, we skip parsing the section of the stop reply packet that contains register data. The register data will be retrieved later after the inferior's architecture has been set up by infrun.c:follow_exec. At that point the exec event is handled by the existing event handling in GDB. However, a few changes were necessary so that infrun.c:follow_exec could accommodate the remote target. * Where follow-exec-mode "new" is handled, we now call add_inferior_with_spaces instead of add_inferior with separate calls to set up the program and address spaces. The motivation for this is that add_inferior_with_spaces also sets up the initial architecture for the inferior, which is needed later by target_find_description when it calls target_gdbarch. * We call a new target function, target_follow_exec. This function allows us to store the execd_pathname in the inferior, instead of using the static string remote_exec_file from remote.c. The static string didn't work for follow-exec-mode "new", since once you switched to the execed program, the original remote exec-file was lost. The execd_pathname is now stored in the inferior's program space as a REGISTRY field. All of the requisite mechanisms for this are defined in remote.c. gdb/gdbserver/ChangeLog: * linux-low.c (linux_mourn): Static declaration. (linux_arch_setup): Move in front of handle_extended_wait. (linux_arch_setup_thread): New function. (handle_extended_wait): Handle exec events. Call linux_arch_setup_thread. Make event_lwp argument a pointer-to-a-pointer. (check_zombie_leaders): Do not check stopped threads. (linux_low_ptrace_options): Add PTRACE_O_TRACEEXEC. (linux_low_filter_event): Add lwp and thread for exec'ing non-leader thread if leader thread has been deleted. Refactor code into linux_arch_setup_thread and call it. Pass child lwp pointer by reference to handle_extended_wait. (linux_wait_for_event_filtered): Update comment. (linux_wait_1): Prevent clobbering exec event status. (linux_supports_exec_events): New function. (linux_target_ops) <supports_exec_events>: Initialize new member. * lynx-low.c (lynx_target_ops) <supports_exec_events>: Initialize new member. * remote-utils.c (prepare_resume_reply): New stop reason 'exec'. * server.c (report_exec_events): New global variable. (handle_query): Handle qSupported query for exec-events feature. (captured_main): Initialize report_exec_events. * server.h (report_exec_events): Declare new global variable. * target.h (struct target_ops) <supports_exec_events>: New member. (target_supports_exec_events): New macro. * win32-low.c (win32_target_ops) <supports_exec_events>: Initialize new member. gdb/ChangeLog: * infrun.c (follow_exec): Use process-style ptid for exec message. Call add_inferior_with_spaces and target_follow_exec. * nat/linux-ptrace.c (linux_supports_traceexec): New function. * nat/linux-ptrace.h (linux_supports_traceexec): Declare. * remote.c (remote_pspace_data): New static variable. (remote_pspace_data_cleanup): New function. (get_remote_exec_file): New function. (set_remote_exec_file_1): New function. (set_remote_exec_file): New function. (show_remote_exec_file): New function. (remote_exec_file): Delete static variable. (anonymous enum) <PACKET_exec_event_feature> New enumeration constant. (remote_protocol_features): Add entry for exec-events feature. (remote_query_supported): Add client side of qSupported query for exec-events feature. (remote_follow_exec): New function. (remote_parse_stop_reply): Handle 'exec' stop reason. (extended_remote_run, extended_remote_create_inferior): Call get_remote_exec_file and set_remote_exec_file_1. (init_extended_remote_ops) <to_follow_exec>: Initialize new member. (_initialize_remote): Call register_program_space_data_with_cleanup. Call add_packet_config_cmd for remote exec-events feature. Modify call to add_setshow_string_noescape_cmd for exec-file to use new functions set_remote_exec_file and show_remote_exec_file. * target-debug.h, target-delegates.c: Regenerated. * target.c (target_follow_exec): New function. * target.h (struct target_ops) <to_follow_exec>: New member. (target_follow_exec): Declare new function.
2015-09-11 20:06:02 +02:00
/* Report the event. */
*orig_event_lwp = event_lwp;
return 0;
}
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
internal_error (__FILE__, __LINE__, _("unknown ptrace event %d"), event);
* inferiors.c (change_inferior_id): Delete. (add_pid_to_list, pull_pid_from_list): New. * linux-low.c (PTRACE_SETOPTIONS, PTRACE_GETEVENTMSG) (PTRACE_O_TRACESYSGOOD, PTRACE_O_TRACEFORK, PTRACE_O_TRACEVFORK) (PTRACE_O_TRACECLONE, PTRACE_O_TRACEEXEC, PTRACE_O_TRACEVFORKDONE) (PTRACE_O_TRACEEXIT, PTRACE_EVENT_FORK, PTRACE_EVENT_VFORK) (PTRACE_EVENT_CLONE, PTRACE_EVENT_EXEC, PTRACE_EVENT_VFORK_DONE) (PTRACE_EVENT_EXIT, __WALL): Provide default definitions. (stopped_pids, thread_db_active, must_set_ptrace_flags): New variables. (using_threads): Always set to 1. (handle_extended_wait): New. (add_process): Do not set TID. (linux_create_inferior): Set must_set_ptrace_flags. (linux_attach_lwp): Remove TID argument. Do not check using_threads. Use PTRACE_SETOPTIONS. Call new_thread_notify. Update all callers. (linux_thread_alive): Rename TID argument to LWPID. (linux_wait_for_process): Handle unknown processes. Do not use TID. (linux_wait_for_event): Do not use TID or check using_threads. Update call to dead_thread_notify. Call handle_extended_wait. (linux_create_inferior): Use PTRACE_SETOPTIONS. (send_sigstop): Delete sigstop_sent. (wait_for_sigstop): Avoid TID. (linux_supports_tracefork_flag, linux_tracefork_child, my_waitpid) (linux_test_for_tracefork): New. (linux_lookup_signals): Use thread_db_active and linux_supports_tracefork_flag. (initialize_low): Use thread_db_active and linux_test_for_tracefork. * linux-low.h (get_process_thread): Avoid TID. (struct process_ifo): Move thread_known and tid to the end. Remove sigstop_sent. (linux_attach_lwp, thread_db_init): Update prototypes. * server.h (change_inferior_id): Delete prototype. (add_pid_to_list, pull_pid_from_list): New prototypes. * thread-db.c (thread_db_use_events): New. (find_first_thread): Rename to... (find_one_thread): ...this. Update callers and messages. Do not call fatal. Check thread_db_use_events. Do not call change_inferior_id or new_thread_notify. (maybe_attach_thread): Update. Do not call new_thread_notify. (thread_db_init): Set thread_db_use_events. Check use_events. * utils.c (fatal, warning): Correct message prefix.
2007-10-23 22:05:03 +02:00
}
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
CORE_ADDR
linux_process_target::get_pc (lwp_info *lwp)
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
{
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
struct thread_info *saved_thread;
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
struct regcache *regcache;
CORE_ADDR pc;
gdbserver/linux-low: turn 'get_pc' and 'set_pc' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_pc' and 'set_pc' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. * linux-low.cc (supports_breakpoints): Turn into... (linux_process_target::low_supports_breakpoints): ...this. (linux_process_target::low_get_pc): Define. (linux_process_target::low_set_pc): Define. Update the callers below. (linux_process_target::get_pc) (linux_process_target::save_stop_reason) (linux_process_target::maybe_move_out_of_jump_pad) (linux_process_target::wait_1) (linux_process_target::resume_one_lwp_throw) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (linux_process_target::read_pc) (linux_process_target::write_pc) * linux-x86-low.cc (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (x86_target::low_supports_breakpoints): Define. (x86_get_pc): Turn into... (x86_target::low_get_pc): ...this. (x86_set_pc): Turn into... (x86_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (arm_target::low_supports_breakpoints) (arm_target::low_get_pc) (arm_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (bfin_target::low_supports_breakpoints) (bfin_target::low_get_pc) (bfin_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (cris_target::low_supports_breakpoints) (cris_target::low_get_pc) (cris_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (crisv32_target::low_supports_breakpoints) (crisv32_target::low_get_pc) (crisv32_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m32r_target::low_supports_breakpoints) (m32r_target::low_get_pc) (m32r_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m68k_target::low_supports_breakpoints) (m68k_target::low_get_pc) (m68k_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (nios2_target::low_supports_breakpoints) (nios2_target::low_get_pc) (nios2_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (sh_target::low_supports_breakpoints) (sh_target::low_get_pc) (sh_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (xtensa_target::low_supports_breakpoints) (xtensa_target::low_get_pc) (xtensa_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_supports_breakpoints> <low_get_pc>: Declare. (sparc_target::low_supports_breakpoints) (sparc_target::low_get_pc): Define. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tile_target::low_supports_breakpoints) (tile_target::low_get_pc) (tile_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (aarch64_target::low_supports_breakpoints): Define. (aarch64_get_pc): Turn into... (aarch64_target::low_get_pc): ...this. (aarch64_set_pc): Turn into... (aarch64_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (mips_target::low_supports_breakpoints): Define. (mips_get_pc): Turn into... (mips_target::low_get_pc): ...this. (mips_set_pc): Turn into... (mips_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (ppc_target::low_supports_breakpoints): Define. (ppc_get_pc): Turn into... (ppc_target::low_get_pc): ...this. (ppc_set_pc): Turn into... (ppc_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (riscv_target::low_supports_breakpoints): Define. (riscv_get_pc): Turn into... (riscv_target::low_get_pc): ...this. (riscv_set_pc): Turn into... (riscv_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (s390_target::low_supports_breakpoints): Define. (s390_get_pc): Turn into... (s390_target::low_get_pc): ...this. (s390_set_pc): Turn into... (s390_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tic6x_target::low_supports_breakpoints): Define. (tic6x_get_pc): Turn into... (tic6x_target::low_get_pc): ...this. (tic6x_set_pc): Turn into... (tic6x_target::low_set_pc): ...this. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
if (!low_supports_breakpoints ())
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
return 0;
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
saved_thread = current_thread;
current_thread = get_lwp_thread (lwp);
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
regcache = get_thread_regcache (current_thread, 1);
gdbserver/linux-low: turn 'get_pc' and 'set_pc' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_pc' and 'set_pc' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. * linux-low.cc (supports_breakpoints): Turn into... (linux_process_target::low_supports_breakpoints): ...this. (linux_process_target::low_get_pc): Define. (linux_process_target::low_set_pc): Define. Update the callers below. (linux_process_target::get_pc) (linux_process_target::save_stop_reason) (linux_process_target::maybe_move_out_of_jump_pad) (linux_process_target::wait_1) (linux_process_target::resume_one_lwp_throw) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (linux_process_target::read_pc) (linux_process_target::write_pc) * linux-x86-low.cc (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (x86_target::low_supports_breakpoints): Define. (x86_get_pc): Turn into... (x86_target::low_get_pc): ...this. (x86_set_pc): Turn into... (x86_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (arm_target::low_supports_breakpoints) (arm_target::low_get_pc) (arm_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (bfin_target::low_supports_breakpoints) (bfin_target::low_get_pc) (bfin_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (cris_target::low_supports_breakpoints) (cris_target::low_get_pc) (cris_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (crisv32_target::low_supports_breakpoints) (crisv32_target::low_get_pc) (crisv32_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m32r_target::low_supports_breakpoints) (m32r_target::low_get_pc) (m32r_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m68k_target::low_supports_breakpoints) (m68k_target::low_get_pc) (m68k_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (nios2_target::low_supports_breakpoints) (nios2_target::low_get_pc) (nios2_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (sh_target::low_supports_breakpoints) (sh_target::low_get_pc) (sh_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (xtensa_target::low_supports_breakpoints) (xtensa_target::low_get_pc) (xtensa_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_supports_breakpoints> <low_get_pc>: Declare. (sparc_target::low_supports_breakpoints) (sparc_target::low_get_pc): Define. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tile_target::low_supports_breakpoints) (tile_target::low_get_pc) (tile_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (aarch64_target::low_supports_breakpoints): Define. (aarch64_get_pc): Turn into... (aarch64_target::low_get_pc): ...this. (aarch64_set_pc): Turn into... (aarch64_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (mips_target::low_supports_breakpoints): Define. (mips_get_pc): Turn into... (mips_target::low_get_pc): ...this. (mips_set_pc): Turn into... (mips_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (ppc_target::low_supports_breakpoints): Define. (ppc_get_pc): Turn into... (ppc_target::low_get_pc): ...this. (ppc_set_pc): Turn into... (ppc_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (riscv_target::low_supports_breakpoints): Define. (riscv_get_pc): Turn into... (riscv_target::low_get_pc): ...this. (riscv_set_pc): Turn into... (riscv_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (s390_target::low_supports_breakpoints): Define. (s390_get_pc): Turn into... (s390_target::low_get_pc): ...this. (s390_set_pc): Turn into... (s390_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tic6x_target::low_supports_breakpoints): Define. (tic6x_get_pc): Turn into... (tic6x_target::low_get_pc): ...this. (tic6x_set_pc): Turn into... (tic6x_target::low_set_pc): ...this. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
pc = low_get_pc (regcache);
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("pc is 0x%lx\n", (long) pc);
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
current_thread = saved_thread;
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
return pc;
}
gdbserver/linux-low: turn 'get_syscall_trapinfo' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_syscall_trapinfo' linux target op into a method of process_stratum_target. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <get_syscall_trapinfo> <gdb_catch_this_syscall> <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. * linux-low.cc (get_syscall_trapinfo): Turn into... (linux_process_target::get_syscall_trapinfo): ...this. (linux_process_target::low_get_syscall_trapinfo): Define. (gdb_catch_this_syscall_p): Turn into... (linux_process_target::gdb_catch_this_syscall): ...this. (linux_process_target::low_supports_catch_syscall): Define. Update the callers below. (linux_process_target::wait_1) (linux_process_target::supports_catch_syscall) * linux-x86-low.cc (class x86_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (x86_target::low_supports_catch_syscall): Define. (x86_get_syscall_trapinfo): Turn into... (x86_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (aarch64_target::low_supports_catch_syscall): Define. (aarch64_get_syscall_trapinfo): Turn into... (aarch64_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (class arm_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (arm_target::low_supports_catch_syscall): Define. (arm_get_syscall_trapinfo): Turn into... (arm_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (the_low_target): Remove the op field. * linux-s390-low.cc (the_low_target): Remove the op field.
2020-04-02 15:11:31 +02:00
void
linux_process_target::get_syscall_trapinfo (lwp_info *lwp, int *sysno)
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
{
struct thread_info *saved_thread;
struct regcache *regcache;
saved_thread = current_thread;
current_thread = get_lwp_thread (lwp);
regcache = get_thread_regcache (current_thread, 1);
gdbserver/linux-low: turn 'get_syscall_trapinfo' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_syscall_trapinfo' linux target op into a method of process_stratum_target. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <get_syscall_trapinfo> <gdb_catch_this_syscall> <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. * linux-low.cc (get_syscall_trapinfo): Turn into... (linux_process_target::get_syscall_trapinfo): ...this. (linux_process_target::low_get_syscall_trapinfo): Define. (gdb_catch_this_syscall_p): Turn into... (linux_process_target::gdb_catch_this_syscall): ...this. (linux_process_target::low_supports_catch_syscall): Define. Update the callers below. (linux_process_target::wait_1) (linux_process_target::supports_catch_syscall) * linux-x86-low.cc (class x86_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (x86_target::low_supports_catch_syscall): Define. (x86_get_syscall_trapinfo): Turn into... (x86_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (aarch64_target::low_supports_catch_syscall): Define. (aarch64_get_syscall_trapinfo): Turn into... (aarch64_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (class arm_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (arm_target::low_supports_catch_syscall): Define. (arm_get_syscall_trapinfo): Turn into... (arm_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (the_low_target): Remove the op field. * linux-s390-low.cc (the_low_target): Remove the op field.
2020-04-02 15:11:31 +02:00
low_get_syscall_trapinfo (regcache, sysno);
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
if (debug_threads)
debug_printf ("get_syscall_trapinfo sysno %d\n", *sysno);
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
current_thread = saved_thread;
}
gdbserver/linux-low: turn 'get_syscall_trapinfo' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_syscall_trapinfo' linux target op into a method of process_stratum_target. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <get_syscall_trapinfo> <gdb_catch_this_syscall> <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. * linux-low.cc (get_syscall_trapinfo): Turn into... (linux_process_target::get_syscall_trapinfo): ...this. (linux_process_target::low_get_syscall_trapinfo): Define. (gdb_catch_this_syscall_p): Turn into... (linux_process_target::gdb_catch_this_syscall): ...this. (linux_process_target::low_supports_catch_syscall): Define. Update the callers below. (linux_process_target::wait_1) (linux_process_target::supports_catch_syscall) * linux-x86-low.cc (class x86_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (x86_target::low_supports_catch_syscall): Define. (x86_get_syscall_trapinfo): Turn into... (x86_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (aarch64_target::low_supports_catch_syscall): Define. (aarch64_get_syscall_trapinfo): Turn into... (aarch64_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (class arm_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (arm_target::low_supports_catch_syscall): Define. (arm_get_syscall_trapinfo): Turn into... (arm_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (the_low_target): Remove the op field. * linux-s390-low.cc (the_low_target): Remove the op field.
2020-04-02 15:11:31 +02:00
void
linux_process_target::low_get_syscall_trapinfo (regcache *regcache, int *sysno)
{
/* By default, report an unknown system call number. */
*sysno = UNKNOWN_SYSCALL;
}
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
bool
linux_process_target::save_stop_reason (lwp_info *lwp)
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
{
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
CORE_ADDR pc;
CORE_ADDR sw_breakpoint_pc;
struct thread_info *saved_thread;
#if USE_SIGTRAP_SIGINFO
siginfo_t siginfo;
#endif
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
gdbserver/linux-low: turn 'get_pc' and 'set_pc' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_pc' and 'set_pc' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. * linux-low.cc (supports_breakpoints): Turn into... (linux_process_target::low_supports_breakpoints): ...this. (linux_process_target::low_get_pc): Define. (linux_process_target::low_set_pc): Define. Update the callers below. (linux_process_target::get_pc) (linux_process_target::save_stop_reason) (linux_process_target::maybe_move_out_of_jump_pad) (linux_process_target::wait_1) (linux_process_target::resume_one_lwp_throw) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (linux_process_target::read_pc) (linux_process_target::write_pc) * linux-x86-low.cc (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (x86_target::low_supports_breakpoints): Define. (x86_get_pc): Turn into... (x86_target::low_get_pc): ...this. (x86_set_pc): Turn into... (x86_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (arm_target::low_supports_breakpoints) (arm_target::low_get_pc) (arm_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (bfin_target::low_supports_breakpoints) (bfin_target::low_get_pc) (bfin_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (cris_target::low_supports_breakpoints) (cris_target::low_get_pc) (cris_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (crisv32_target::low_supports_breakpoints) (crisv32_target::low_get_pc) (crisv32_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m32r_target::low_supports_breakpoints) (m32r_target::low_get_pc) (m32r_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m68k_target::low_supports_breakpoints) (m68k_target::low_get_pc) (m68k_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (nios2_target::low_supports_breakpoints) (nios2_target::low_get_pc) (nios2_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (sh_target::low_supports_breakpoints) (sh_target::low_get_pc) (sh_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (xtensa_target::low_supports_breakpoints) (xtensa_target::low_get_pc) (xtensa_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_supports_breakpoints> <low_get_pc>: Declare. (sparc_target::low_supports_breakpoints) (sparc_target::low_get_pc): Define. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tile_target::low_supports_breakpoints) (tile_target::low_get_pc) (tile_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (aarch64_target::low_supports_breakpoints): Define. (aarch64_get_pc): Turn into... (aarch64_target::low_get_pc): ...this. (aarch64_set_pc): Turn into... (aarch64_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (mips_target::low_supports_breakpoints): Define. (mips_get_pc): Turn into... (mips_target::low_get_pc): ...this. (mips_set_pc): Turn into... (mips_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (ppc_target::low_supports_breakpoints): Define. (ppc_get_pc): Turn into... (ppc_target::low_get_pc): ...this. (ppc_set_pc): Turn into... (ppc_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (riscv_target::low_supports_breakpoints): Define. (riscv_get_pc): Turn into... (riscv_target::low_get_pc): ...this. (riscv_set_pc): Turn into... (riscv_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (s390_target::low_supports_breakpoints): Define. (s390_get_pc): Turn into... (s390_target::low_get_pc): ...this. (s390_set_pc): Turn into... (s390_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tic6x_target::low_supports_breakpoints): Define. (tic6x_get_pc): Turn into... (tic6x_target::low_get_pc): ...this. (tic6x_set_pc): Turn into... (tic6x_target::low_set_pc): ...this. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
if (!low_supports_breakpoints ())
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
return false;
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
pc = get_pc (lwp);
gdbserver/linux-low: turn the 'decr_pc_after_break' field into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'decr_pc_after_break' linux_target_ops field into a method of linux_process_target. * linux-low.h (struct linux_target_ops) <decr_pc_after_break>: Remove. (class linux_process_target) <low_decr_pc_after_break>: New method declaration. * linux-low.cc (linux_process_target::low_decr_pc_after_break): New method implementation. Update the users below. (linux_process_target::save_stop_reason) (linux_process_target::wait_1) * linux-x86-low.cc (class x86_target) <low_decr_pc_after_break>: New declaration. (x86_target::low_decr_pc_after_break): New method implementation. (the_low_target): Remove the field. * linux-bfin-low.cc (class bfin_target) <low_decr_pc_after_break>: New declaration. (bfin_target::low_decr_pc_after_break): New method implementation. (the_low_target): Remove the field. * linux-m68k-low.cc (class m68k_target) <low_decr_pc_after_break>: New declaration. (m68k_target::low_decr_pc_after_break): New method implementation. (the_low_target): Remove the field. * linux-s390-low.cc (class s390_target) <low_decr_pc_after_break>: New declaration. (s390_target::low_decr_pc_after_break): New method implementation. (the_low_target): Remove the field. * linux-aarch64-low.cc (the_low_target): Remove the field. * linux-arm-low.cc (the_low_target): Remove the field. * linux-cris-low.cc (the_low_target): Remove the field. * linux-crisv32-low.cc (the_low_target): Remove the field. * linux-m32r-low.cc (the_low_target): Remove the field. * linux-mips-low.cc (the_low_target): Remove the field. * linux-nios2-low.cc (the_low_target): Remove the field. * linux-ppc-low.cc (the_low_target): Remove the field. * linux-riscv-low.cc (the_low_target): Remove the field. * linux-sh-low.cc (the_low_target): Remove the field. * linux-sparc-low.cc (the_low_target): Remove the field. * linux-tic6x-low.cc (the_low_target): Remove the field. * linux-tile-low.cc (the_low_target): Remove the field. * linux-xtensa-low.cc (the_low_target): Remove the field.
2020-04-02 15:11:26 +02:00
sw_breakpoint_pc = pc - low_decr_pc_after_break ();
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
/* breakpoint_at reads from the current thread. */
saved_thread = current_thread;
current_thread = get_lwp_thread (lwp);
#if USE_SIGTRAP_SIGINFO
if (ptrace (PTRACE_GETSIGINFO, lwpid_of (current_thread),
(PTRACE_TYPE_ARG3) 0, &siginfo) == 0)
{
if (siginfo.si_signo == SIGTRAP)
{
Handle MIPS Linux SIGTRAP siginfo.si_code values This unbreaks pending/delayed breakpoints handling, as well as hardware watchpoints, on MIPS. Ref: https://sourceware.org/ml/gdb-patches/2016-02/msg00681.html The MIPS kernel reports SI_KERNEL for all kernel generated traps, instead of TRAP_BRKPT / TRAP_HWBKPT, but GDB isn't aware of this. Basically, this commit: - Folds watchpoints logic into check_stopped_by_breakpoint, and renames it to save_stop_reason. - Adds GDB_ARCH_IS_TRAP_HWBKPT. - Makes MIPS set both GDB_ARCH_IS_TRAP_BRPT and GDB_ARCH_IS_TRAP_HWBKPT to SI_KERNEL. In save_stop_reason, we handle the case of the same si_code returning true for both TRAP_BRPT and TRAP_HWBKPT by looking at what the debug registers say. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-nat.c (save_sigtrap) Delete. (stop_wait_callback): Call save_stop_reason instead of save_sigtrap. (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Bits of save_sigtrap folded here. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_nat_filter_event): Call save_stop_reason instead of save_sigtrap. * nat/linux-ptrace.h: Check for both SI_KERNEL and TRAP_BRKPT si_code for MIPS. * nat/linux-ptrace.h: Fix "TRAP_HWBPT" typo in x86 table. Add comments on MIPS behavior. (GDB_ARCH_IS_TRAP_HWBKPT): Define for all archs. gdb/gdbserver/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-low.c (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_low_filter_event): Call save_stop_reason instead of check_stopped_by_breakpoint and check_stopped_by_watchpoint. Update comments. (linux_wait_1): Update comments.
2016-02-24 23:52:06 +01:00
if (GDB_ARCH_IS_TRAP_BRKPT (siginfo.si_code)
&& GDB_ARCH_IS_TRAP_HWBKPT (siginfo.si_code))
{
Handle MIPS Linux SIGTRAP siginfo.si_code values This unbreaks pending/delayed breakpoints handling, as well as hardware watchpoints, on MIPS. Ref: https://sourceware.org/ml/gdb-patches/2016-02/msg00681.html The MIPS kernel reports SI_KERNEL for all kernel generated traps, instead of TRAP_BRKPT / TRAP_HWBKPT, but GDB isn't aware of this. Basically, this commit: - Folds watchpoints logic into check_stopped_by_breakpoint, and renames it to save_stop_reason. - Adds GDB_ARCH_IS_TRAP_HWBKPT. - Makes MIPS set both GDB_ARCH_IS_TRAP_BRPT and GDB_ARCH_IS_TRAP_HWBKPT to SI_KERNEL. In save_stop_reason, we handle the case of the same si_code returning true for both TRAP_BRPT and TRAP_HWBKPT by looking at what the debug registers say. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-nat.c (save_sigtrap) Delete. (stop_wait_callback): Call save_stop_reason instead of save_sigtrap. (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Bits of save_sigtrap folded here. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_nat_filter_event): Call save_stop_reason instead of save_sigtrap. * nat/linux-ptrace.h: Check for both SI_KERNEL and TRAP_BRKPT si_code for MIPS. * nat/linux-ptrace.h: Fix "TRAP_HWBPT" typo in x86 table. Add comments on MIPS behavior. (GDB_ARCH_IS_TRAP_HWBKPT): Define for all archs. gdb/gdbserver/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-low.c (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_low_filter_event): Call save_stop_reason instead of check_stopped_by_breakpoint and check_stopped_by_watchpoint. Update comments. (linux_wait_1): Update comments.
2016-02-24 23:52:06 +01:00
/* The si_code is ambiguous on this arch -- check debug
registers. */
if (!check_stopped_by_watchpoint (lwp))
lwp->stop_reason = TARGET_STOPPED_BY_SW_BREAKPOINT;
}
else if (GDB_ARCH_IS_TRAP_BRKPT (siginfo.si_code))
{
/* If we determine the LWP stopped for a SW breakpoint,
trust it. Particularly don't check watchpoint
registers, because at least on s390, we'd find
stopped-by-watchpoint as long as there's a watchpoint
set. */
lwp->stop_reason = TARGET_STOPPED_BY_SW_BREAKPOINT;
}
Handle MIPS Linux SIGTRAP siginfo.si_code values This unbreaks pending/delayed breakpoints handling, as well as hardware watchpoints, on MIPS. Ref: https://sourceware.org/ml/gdb-patches/2016-02/msg00681.html The MIPS kernel reports SI_KERNEL for all kernel generated traps, instead of TRAP_BRKPT / TRAP_HWBKPT, but GDB isn't aware of this. Basically, this commit: - Folds watchpoints logic into check_stopped_by_breakpoint, and renames it to save_stop_reason. - Adds GDB_ARCH_IS_TRAP_HWBKPT. - Makes MIPS set both GDB_ARCH_IS_TRAP_BRPT and GDB_ARCH_IS_TRAP_HWBKPT to SI_KERNEL. In save_stop_reason, we handle the case of the same si_code returning true for both TRAP_BRPT and TRAP_HWBKPT by looking at what the debug registers say. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-nat.c (save_sigtrap) Delete. (stop_wait_callback): Call save_stop_reason instead of save_sigtrap. (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Bits of save_sigtrap folded here. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_nat_filter_event): Call save_stop_reason instead of save_sigtrap. * nat/linux-ptrace.h: Check for both SI_KERNEL and TRAP_BRKPT si_code for MIPS. * nat/linux-ptrace.h: Fix "TRAP_HWBPT" typo in x86 table. Add comments on MIPS behavior. (GDB_ARCH_IS_TRAP_HWBKPT): Define for all archs. gdb/gdbserver/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-low.c (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_low_filter_event): Call save_stop_reason instead of check_stopped_by_breakpoint and check_stopped_by_watchpoint. Update comments. (linux_wait_1): Update comments.
2016-02-24 23:52:06 +01:00
else if (GDB_ARCH_IS_TRAP_HWBKPT (siginfo.si_code))
{
Handle MIPS Linux SIGTRAP siginfo.si_code values This unbreaks pending/delayed breakpoints handling, as well as hardware watchpoints, on MIPS. Ref: https://sourceware.org/ml/gdb-patches/2016-02/msg00681.html The MIPS kernel reports SI_KERNEL for all kernel generated traps, instead of TRAP_BRKPT / TRAP_HWBKPT, but GDB isn't aware of this. Basically, this commit: - Folds watchpoints logic into check_stopped_by_breakpoint, and renames it to save_stop_reason. - Adds GDB_ARCH_IS_TRAP_HWBKPT. - Makes MIPS set both GDB_ARCH_IS_TRAP_BRPT and GDB_ARCH_IS_TRAP_HWBKPT to SI_KERNEL. In save_stop_reason, we handle the case of the same si_code returning true for both TRAP_BRPT and TRAP_HWBKPT by looking at what the debug registers say. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-nat.c (save_sigtrap) Delete. (stop_wait_callback): Call save_stop_reason instead of save_sigtrap. (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Bits of save_sigtrap folded here. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_nat_filter_event): Call save_stop_reason instead of save_sigtrap. * nat/linux-ptrace.h: Check for both SI_KERNEL and TRAP_BRKPT si_code for MIPS. * nat/linux-ptrace.h: Fix "TRAP_HWBPT" typo in x86 table. Add comments on MIPS behavior. (GDB_ARCH_IS_TRAP_HWBKPT): Define for all archs. gdb/gdbserver/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-low.c (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_low_filter_event): Call save_stop_reason instead of check_stopped_by_breakpoint and check_stopped_by_watchpoint. Update comments. (linux_wait_1): Update comments.
2016-02-24 23:52:06 +01:00
/* This can indicate either a hardware breakpoint or
hardware watchpoint. Check debug registers. */
if (!check_stopped_by_watchpoint (lwp))
lwp->stop_reason = TARGET_STOPPED_BY_HW_BREAKPOINT;
}
else if (siginfo.si_code == TRAP_TRACE)
{
Handle MIPS Linux SIGTRAP siginfo.si_code values This unbreaks pending/delayed breakpoints handling, as well as hardware watchpoints, on MIPS. Ref: https://sourceware.org/ml/gdb-patches/2016-02/msg00681.html The MIPS kernel reports SI_KERNEL for all kernel generated traps, instead of TRAP_BRKPT / TRAP_HWBKPT, but GDB isn't aware of this. Basically, this commit: - Folds watchpoints logic into check_stopped_by_breakpoint, and renames it to save_stop_reason. - Adds GDB_ARCH_IS_TRAP_HWBKPT. - Makes MIPS set both GDB_ARCH_IS_TRAP_BRPT and GDB_ARCH_IS_TRAP_HWBKPT to SI_KERNEL. In save_stop_reason, we handle the case of the same si_code returning true for both TRAP_BRPT and TRAP_HWBKPT by looking at what the debug registers say. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-nat.c (save_sigtrap) Delete. (stop_wait_callback): Call save_stop_reason instead of save_sigtrap. (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Bits of save_sigtrap folded here. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_nat_filter_event): Call save_stop_reason instead of save_sigtrap. * nat/linux-ptrace.h: Check for both SI_KERNEL and TRAP_BRKPT si_code for MIPS. * nat/linux-ptrace.h: Fix "TRAP_HWBPT" typo in x86 table. Add comments on MIPS behavior. (GDB_ARCH_IS_TRAP_HWBKPT): Define for all archs. gdb/gdbserver/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-low.c (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_low_filter_event): Call save_stop_reason instead of check_stopped_by_breakpoint and check_stopped_by_watchpoint. Update comments. (linux_wait_1): Update comments.
2016-02-24 23:52:06 +01:00
/* We may have single stepped an instruction that
triggered a watchpoint. In that case, on some
architectures (such as x86), instead of TRAP_HWBKPT,
si_code indicates TRAP_TRACE, and we need to check
the debug registers separately. */
if (!check_stopped_by_watchpoint (lwp))
lwp->stop_reason = TARGET_STOPPED_BY_SINGLE_STEP;
}
}
}
#else
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
/* We may have just stepped a breakpoint instruction. E.g., in
non-stop mode, GDB first tells the thread A to step a range, and
then the user inserts a breakpoint inside the range. In that
case we need to report the breakpoint PC. */
if ((!lwp->stepping || lwp->stop_pc == sw_breakpoint_pc)
gdbserver/linux-low: turn 'breakpoint_at' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'breakpoint_at' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <low_breakpoint_at>: Declare. Update the callers below: * linux-low.cc (linux_process_target::save_stop_reason) (linux_process_target::thread_still_has_status_pending) (linux_process_target::wait_1) * linux-x86-low.cc (class x86_target) <low_breakpoint_at>: Declare. (x86_breakpoint_at): Turn into... (x86_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <low_breakpoint_at>: Declare. (aarch64_breakpoint_at): Turn into... (aarch64_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (class arm_target) <low_breakpoint_at>: Declare. (arm_target::low_breakpoint_at): Define. (the_low_target): Remove the op field. * linux-bfin-low.cc (class bfin_target) <low_breakpoint_at>: Declare. (bfin_breakpoint_at): Turn into... (bfin_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-cris-low.cc (class cris_target) <low_breakpoint_at>: Declare. (cris_breakpoint_at): Turn into... (cris_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-crisv32-low.cc (class crisv32_target) <low_breakpoint_at>: Declare. (crisv32_breakpoint_at): Turn into... (crisv32_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-ia64-low.cc (class ia64_target) <low_breakpoint_at>: Declare. (ia64_target::low_breakpoint_at): Define. * linux-m32r-low.cc (class m32r_target) <low_breakpoint_at>: Declare. (m32r_breakpoint_at): Turn into... (m32r_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-m68k-low.cc (class m68k_target) <low_breakpoint_at>: Declare. (m68k_breakpoint_at): Turn into... (m68k_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-mips-low.cc (class mips_target) <low_breakpoint_at>: Declare. (mips_breakpoint_at): Turn into... (mips_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-nios2-low.cc (class nios2_target) <low_breakpoint_at>: Declare. (nios2_breakpoint_at): Turn into... (nios2_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (class ppc_target) <low_breakpoint_at>: Declare. (ppc_breakpoint_at): Turn into... (ppc_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-riscv-low.cc (class riscv_target) <low_breakpoint_at>: Declare. (riscv_breakpoint_at): Turn into... (riscv_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-s390-low.cc (class s390_target) <low_breakpoint_at>: Declare. (s390_breakpoint_at): Turn into... (s390_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-sh-low.cc (class sh_target) <low_breakpoint_at>: Declare. (sh_breakpoint_at): Turn into... (sh_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-sparc-low.cc (class sparc_target) <low_breakpoint_at>: Declare. (sparc_breakpoint_at): Turn into... (sparc_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-tic6x-low.cc (class tic6x_target) <low_breakpoint_at>: Declare. (tic6x_breakpoint_at): Turn into... (tic6x_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-tile-low.cc (class tile_target) <low_breakpoint_at>: Declare. (tile_breakpoint_at): Turn into... (tile_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-xtensa-low.cc (class xtensa_target) <low_breakpoint_at>: Declare. (xtensa_breakpoint_at): Turn into... (xtensa_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field.
2020-04-02 15:11:26 +02:00
&& low_breakpoint_at (sw_breakpoint_pc))
Handle MIPS Linux SIGTRAP siginfo.si_code values This unbreaks pending/delayed breakpoints handling, as well as hardware watchpoints, on MIPS. Ref: https://sourceware.org/ml/gdb-patches/2016-02/msg00681.html The MIPS kernel reports SI_KERNEL for all kernel generated traps, instead of TRAP_BRKPT / TRAP_HWBKPT, but GDB isn't aware of this. Basically, this commit: - Folds watchpoints logic into check_stopped_by_breakpoint, and renames it to save_stop_reason. - Adds GDB_ARCH_IS_TRAP_HWBKPT. - Makes MIPS set both GDB_ARCH_IS_TRAP_BRPT and GDB_ARCH_IS_TRAP_HWBKPT to SI_KERNEL. In save_stop_reason, we handle the case of the same si_code returning true for both TRAP_BRPT and TRAP_HWBKPT by looking at what the debug registers say. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-nat.c (save_sigtrap) Delete. (stop_wait_callback): Call save_stop_reason instead of save_sigtrap. (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Bits of save_sigtrap folded here. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_nat_filter_event): Call save_stop_reason instead of save_sigtrap. * nat/linux-ptrace.h: Check for both SI_KERNEL and TRAP_BRKPT si_code for MIPS. * nat/linux-ptrace.h: Fix "TRAP_HWBPT" typo in x86 table. Add comments on MIPS behavior. (GDB_ARCH_IS_TRAP_HWBKPT): Define for all archs. gdb/gdbserver/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-low.c (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_low_filter_event): Call save_stop_reason instead of check_stopped_by_breakpoint and check_stopped_by_watchpoint. Update comments. (linux_wait_1): Update comments.
2016-02-24 23:52:06 +01:00
lwp->stop_reason = TARGET_STOPPED_BY_SW_BREAKPOINT;
if (hardware_breakpoint_inserted_here (pc))
lwp->stop_reason = TARGET_STOPPED_BY_HW_BREAKPOINT;
if (lwp->stop_reason == TARGET_STOPPED_BY_NO_REASON)
check_stopped_by_watchpoint (lwp);
#endif
if (lwp->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT)
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
{
if (debug_threads)
{
struct thread_info *thr = get_lwp_thread (lwp);
debug_printf ("CSBB: %s stopped by software breakpoint\n",
target_pid_to_str (ptid_of (thr)));
}
/* Back up the PC if necessary. */
if (pc != sw_breakpoint_pc)
Handle MIPS Linux SIGTRAP siginfo.si_code values This unbreaks pending/delayed breakpoints handling, as well as hardware watchpoints, on MIPS. Ref: https://sourceware.org/ml/gdb-patches/2016-02/msg00681.html The MIPS kernel reports SI_KERNEL for all kernel generated traps, instead of TRAP_BRKPT / TRAP_HWBKPT, but GDB isn't aware of this. Basically, this commit: - Folds watchpoints logic into check_stopped_by_breakpoint, and renames it to save_stop_reason. - Adds GDB_ARCH_IS_TRAP_HWBKPT. - Makes MIPS set both GDB_ARCH_IS_TRAP_BRPT and GDB_ARCH_IS_TRAP_HWBKPT to SI_KERNEL. In save_stop_reason, we handle the case of the same si_code returning true for both TRAP_BRPT and TRAP_HWBKPT by looking at what the debug registers say. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-nat.c (save_sigtrap) Delete. (stop_wait_callback): Call save_stop_reason instead of save_sigtrap. (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Bits of save_sigtrap folded here. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_nat_filter_event): Call save_stop_reason instead of save_sigtrap. * nat/linux-ptrace.h: Check for both SI_KERNEL and TRAP_BRKPT si_code for MIPS. * nat/linux-ptrace.h: Fix "TRAP_HWBPT" typo in x86 table. Add comments on MIPS behavior. (GDB_ARCH_IS_TRAP_HWBKPT): Define for all archs. gdb/gdbserver/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-low.c (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_low_filter_event): Call save_stop_reason instead of check_stopped_by_breakpoint and check_stopped_by_watchpoint. Update comments. (linux_wait_1): Update comments.
2016-02-24 23:52:06 +01:00
{
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
struct regcache *regcache
= get_thread_regcache (current_thread, 1);
gdbserver/linux-low: turn 'get_pc' and 'set_pc' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_pc' and 'set_pc' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. * linux-low.cc (supports_breakpoints): Turn into... (linux_process_target::low_supports_breakpoints): ...this. (linux_process_target::low_get_pc): Define. (linux_process_target::low_set_pc): Define. Update the callers below. (linux_process_target::get_pc) (linux_process_target::save_stop_reason) (linux_process_target::maybe_move_out_of_jump_pad) (linux_process_target::wait_1) (linux_process_target::resume_one_lwp_throw) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (linux_process_target::read_pc) (linux_process_target::write_pc) * linux-x86-low.cc (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (x86_target::low_supports_breakpoints): Define. (x86_get_pc): Turn into... (x86_target::low_get_pc): ...this. (x86_set_pc): Turn into... (x86_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (arm_target::low_supports_breakpoints) (arm_target::low_get_pc) (arm_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (bfin_target::low_supports_breakpoints) (bfin_target::low_get_pc) (bfin_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (cris_target::low_supports_breakpoints) (cris_target::low_get_pc) (cris_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (crisv32_target::low_supports_breakpoints) (crisv32_target::low_get_pc) (crisv32_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m32r_target::low_supports_breakpoints) (m32r_target::low_get_pc) (m32r_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m68k_target::low_supports_breakpoints) (m68k_target::low_get_pc) (m68k_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (nios2_target::low_supports_breakpoints) (nios2_target::low_get_pc) (nios2_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (sh_target::low_supports_breakpoints) (sh_target::low_get_pc) (sh_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (xtensa_target::low_supports_breakpoints) (xtensa_target::low_get_pc) (xtensa_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_supports_breakpoints> <low_get_pc>: Declare. (sparc_target::low_supports_breakpoints) (sparc_target::low_get_pc): Define. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tile_target::low_supports_breakpoints) (tile_target::low_get_pc) (tile_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (aarch64_target::low_supports_breakpoints): Define. (aarch64_get_pc): Turn into... (aarch64_target::low_get_pc): ...this. (aarch64_set_pc): Turn into... (aarch64_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (mips_target::low_supports_breakpoints): Define. (mips_get_pc): Turn into... (mips_target::low_get_pc): ...this. (mips_set_pc): Turn into... (mips_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (ppc_target::low_supports_breakpoints): Define. (ppc_get_pc): Turn into... (ppc_target::low_get_pc): ...this. (ppc_set_pc): Turn into... (ppc_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (riscv_target::low_supports_breakpoints): Define. (riscv_get_pc): Turn into... (riscv_target::low_get_pc): ...this. (riscv_set_pc): Turn into... (riscv_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (s390_target::low_supports_breakpoints): Define. (s390_get_pc): Turn into... (s390_target::low_get_pc): ...this. (s390_set_pc): Turn into... (s390_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tic6x_target::low_supports_breakpoints): Define. (tic6x_get_pc): Turn into... (tic6x_target::low_get_pc): ...this. (tic6x_set_pc): Turn into... (tic6x_target::low_set_pc): ...this. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
low_set_pc (regcache, sw_breakpoint_pc);
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
}
Handle MIPS Linux SIGTRAP siginfo.si_code values This unbreaks pending/delayed breakpoints handling, as well as hardware watchpoints, on MIPS. Ref: https://sourceware.org/ml/gdb-patches/2016-02/msg00681.html The MIPS kernel reports SI_KERNEL for all kernel generated traps, instead of TRAP_BRKPT / TRAP_HWBKPT, but GDB isn't aware of this. Basically, this commit: - Folds watchpoints logic into check_stopped_by_breakpoint, and renames it to save_stop_reason. - Adds GDB_ARCH_IS_TRAP_HWBKPT. - Makes MIPS set both GDB_ARCH_IS_TRAP_BRPT and GDB_ARCH_IS_TRAP_HWBKPT to SI_KERNEL. In save_stop_reason, we handle the case of the same si_code returning true for both TRAP_BRPT and TRAP_HWBKPT by looking at what the debug registers say. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-nat.c (save_sigtrap) Delete. (stop_wait_callback): Call save_stop_reason instead of save_sigtrap. (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Bits of save_sigtrap folded here. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_nat_filter_event): Call save_stop_reason instead of save_sigtrap. * nat/linux-ptrace.h: Check for both SI_KERNEL and TRAP_BRKPT si_code for MIPS. * nat/linux-ptrace.h: Fix "TRAP_HWBPT" typo in x86 table. Add comments on MIPS behavior. (GDB_ARCH_IS_TRAP_HWBKPT): Define for all archs. gdb/gdbserver/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-low.c (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_low_filter_event): Call save_stop_reason instead of check_stopped_by_breakpoint and check_stopped_by_watchpoint. Update comments. (linux_wait_1): Update comments.
2016-02-24 23:52:06 +01:00
/* Update this so we record the correct stop PC below. */
pc = sw_breakpoint_pc;
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
}
Handle MIPS Linux SIGTRAP siginfo.si_code values This unbreaks pending/delayed breakpoints handling, as well as hardware watchpoints, on MIPS. Ref: https://sourceware.org/ml/gdb-patches/2016-02/msg00681.html The MIPS kernel reports SI_KERNEL for all kernel generated traps, instead of TRAP_BRKPT / TRAP_HWBKPT, but GDB isn't aware of this. Basically, this commit: - Folds watchpoints logic into check_stopped_by_breakpoint, and renames it to save_stop_reason. - Adds GDB_ARCH_IS_TRAP_HWBKPT. - Makes MIPS set both GDB_ARCH_IS_TRAP_BRPT and GDB_ARCH_IS_TRAP_HWBKPT to SI_KERNEL. In save_stop_reason, we handle the case of the same si_code returning true for both TRAP_BRPT and TRAP_HWBKPT by looking at what the debug registers say. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-nat.c (save_sigtrap) Delete. (stop_wait_callback): Call save_stop_reason instead of save_sigtrap. (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Bits of save_sigtrap folded here. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_nat_filter_event): Call save_stop_reason instead of save_sigtrap. * nat/linux-ptrace.h: Check for both SI_KERNEL and TRAP_BRKPT si_code for MIPS. * nat/linux-ptrace.h: Fix "TRAP_HWBPT" typo in x86 table. Add comments on MIPS behavior. (GDB_ARCH_IS_TRAP_HWBKPT): Define for all archs. gdb/gdbserver/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-low.c (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_low_filter_event): Call save_stop_reason instead of check_stopped_by_breakpoint and check_stopped_by_watchpoint. Update comments. (linux_wait_1): Update comments.
2016-02-24 23:52:06 +01:00
else if (lwp->stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT)
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
{
if (debug_threads)
{
struct thread_info *thr = get_lwp_thread (lwp);
debug_printf ("CSBB: %s stopped by hardware breakpoint\n",
target_pid_to_str (ptid_of (thr)));
}
Handle MIPS Linux SIGTRAP siginfo.si_code values This unbreaks pending/delayed breakpoints handling, as well as hardware watchpoints, on MIPS. Ref: https://sourceware.org/ml/gdb-patches/2016-02/msg00681.html The MIPS kernel reports SI_KERNEL for all kernel generated traps, instead of TRAP_BRKPT / TRAP_HWBKPT, but GDB isn't aware of this. Basically, this commit: - Folds watchpoints logic into check_stopped_by_breakpoint, and renames it to save_stop_reason. - Adds GDB_ARCH_IS_TRAP_HWBKPT. - Makes MIPS set both GDB_ARCH_IS_TRAP_BRPT and GDB_ARCH_IS_TRAP_HWBKPT to SI_KERNEL. In save_stop_reason, we handle the case of the same si_code returning true for both TRAP_BRPT and TRAP_HWBKPT by looking at what the debug registers say. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-nat.c (save_sigtrap) Delete. (stop_wait_callback): Call save_stop_reason instead of save_sigtrap. (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Bits of save_sigtrap folded here. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_nat_filter_event): Call save_stop_reason instead of save_sigtrap. * nat/linux-ptrace.h: Check for both SI_KERNEL and TRAP_BRKPT si_code for MIPS. * nat/linux-ptrace.h: Fix "TRAP_HWBPT" typo in x86 table. Add comments on MIPS behavior. (GDB_ARCH_IS_TRAP_HWBKPT): Define for all archs. gdb/gdbserver/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-low.c (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_low_filter_event): Call save_stop_reason instead of check_stopped_by_breakpoint and check_stopped_by_watchpoint. Update comments. (linux_wait_1): Update comments.
2016-02-24 23:52:06 +01:00
}
else if (lwp->stop_reason == TARGET_STOPPED_BY_WATCHPOINT)
{
if (debug_threads)
{
struct thread_info *thr = get_lwp_thread (lwp);
Handle MIPS Linux SIGTRAP siginfo.si_code values This unbreaks pending/delayed breakpoints handling, as well as hardware watchpoints, on MIPS. Ref: https://sourceware.org/ml/gdb-patches/2016-02/msg00681.html The MIPS kernel reports SI_KERNEL for all kernel generated traps, instead of TRAP_BRKPT / TRAP_HWBKPT, but GDB isn't aware of this. Basically, this commit: - Folds watchpoints logic into check_stopped_by_breakpoint, and renames it to save_stop_reason. - Adds GDB_ARCH_IS_TRAP_HWBKPT. - Makes MIPS set both GDB_ARCH_IS_TRAP_BRPT and GDB_ARCH_IS_TRAP_HWBKPT to SI_KERNEL. In save_stop_reason, we handle the case of the same si_code returning true for both TRAP_BRPT and TRAP_HWBKPT by looking at what the debug registers say. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-nat.c (save_sigtrap) Delete. (stop_wait_callback): Call save_stop_reason instead of save_sigtrap. (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Bits of save_sigtrap folded here. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_nat_filter_event): Call save_stop_reason instead of save_sigtrap. * nat/linux-ptrace.h: Check for both SI_KERNEL and TRAP_BRKPT si_code for MIPS. * nat/linux-ptrace.h: Fix "TRAP_HWBPT" typo in x86 table. Add comments on MIPS behavior. (GDB_ARCH_IS_TRAP_HWBKPT): Define for all archs. gdb/gdbserver/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-low.c (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_low_filter_event): Call save_stop_reason instead of check_stopped_by_breakpoint and check_stopped_by_watchpoint. Update comments. (linux_wait_1): Update comments.
2016-02-24 23:52:06 +01:00
debug_printf ("CSBB: %s stopped by hardware watchpoint\n",
target_pid_to_str (ptid_of (thr)));
}
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
}
Handle MIPS Linux SIGTRAP siginfo.si_code values This unbreaks pending/delayed breakpoints handling, as well as hardware watchpoints, on MIPS. Ref: https://sourceware.org/ml/gdb-patches/2016-02/msg00681.html The MIPS kernel reports SI_KERNEL for all kernel generated traps, instead of TRAP_BRKPT / TRAP_HWBKPT, but GDB isn't aware of this. Basically, this commit: - Folds watchpoints logic into check_stopped_by_breakpoint, and renames it to save_stop_reason. - Adds GDB_ARCH_IS_TRAP_HWBKPT. - Makes MIPS set both GDB_ARCH_IS_TRAP_BRPT and GDB_ARCH_IS_TRAP_HWBKPT to SI_KERNEL. In save_stop_reason, we handle the case of the same si_code returning true for both TRAP_BRPT and TRAP_HWBKPT by looking at what the debug registers say. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-nat.c (save_sigtrap) Delete. (stop_wait_callback): Call save_stop_reason instead of save_sigtrap. (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Bits of save_sigtrap folded here. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_nat_filter_event): Call save_stop_reason instead of save_sigtrap. * nat/linux-ptrace.h: Check for both SI_KERNEL and TRAP_BRKPT si_code for MIPS. * nat/linux-ptrace.h: Fix "TRAP_HWBPT" typo in x86 table. Add comments on MIPS behavior. (GDB_ARCH_IS_TRAP_HWBKPT): Define for all archs. gdb/gdbserver/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-low.c (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_low_filter_event): Call save_stop_reason instead of check_stopped_by_breakpoint and check_stopped_by_watchpoint. Update comments. (linux_wait_1): Update comments.
2016-02-24 23:52:06 +01:00
else if (lwp->stop_reason == TARGET_STOPPED_BY_SINGLE_STEP)
{
if (debug_threads)
{
struct thread_info *thr = get_lwp_thread (lwp);
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
Handle MIPS Linux SIGTRAP siginfo.si_code values This unbreaks pending/delayed breakpoints handling, as well as hardware watchpoints, on MIPS. Ref: https://sourceware.org/ml/gdb-patches/2016-02/msg00681.html The MIPS kernel reports SI_KERNEL for all kernel generated traps, instead of TRAP_BRKPT / TRAP_HWBKPT, but GDB isn't aware of this. Basically, this commit: - Folds watchpoints logic into check_stopped_by_breakpoint, and renames it to save_stop_reason. - Adds GDB_ARCH_IS_TRAP_HWBKPT. - Makes MIPS set both GDB_ARCH_IS_TRAP_BRPT and GDB_ARCH_IS_TRAP_HWBKPT to SI_KERNEL. In save_stop_reason, we handle the case of the same si_code returning true for both TRAP_BRPT and TRAP_HWBKPT by looking at what the debug registers say. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-nat.c (save_sigtrap) Delete. (stop_wait_callback): Call save_stop_reason instead of save_sigtrap. (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Bits of save_sigtrap folded here. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_nat_filter_event): Call save_stop_reason instead of save_sigtrap. * nat/linux-ptrace.h: Check for both SI_KERNEL and TRAP_BRKPT si_code for MIPS. * nat/linux-ptrace.h: Fix "TRAP_HWBPT" typo in x86 table. Add comments on MIPS behavior. (GDB_ARCH_IS_TRAP_HWBKPT): Define for all archs. gdb/gdbserver/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-low.c (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_low_filter_event): Call save_stop_reason instead of check_stopped_by_breakpoint and check_stopped_by_watchpoint. Update comments. (linux_wait_1): Update comments.
2016-02-24 23:52:06 +01:00
debug_printf ("CSBB: %s stopped by trace\n",
target_pid_to_str (ptid_of (thr)));
}
}
lwp->stop_pc = pc;
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
current_thread = saved_thread;
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
return true;
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
}
2002-04-09 Daniel Jacobowitz <drow@mvista.com> * gdbserver/inferiors.c: New file. * gdbserver/target.c: New file. * gdbserver/target.h: New file. * gdbserver/Makefile.in: Add target.o and inferiors.o. Update dependencies. * gdbserver/linux-low.c (inferior_pid): New static variable, moved from server.c. (linux_create_inferior): Renamed from create_inferior. Call add_inferior. Return 0 on success instead of a PID. (linux_attach): Renamed from myattach. (linux_kill): Renamed from kill_inferior. Call clear_inferiors (). (linux_thread_alive): Renamed from mythread_alive. (linux_wait): Renamed from mywait. Call clear_inferiors () if the child dies. (linux_resume): Renamed from myresume. Add missing ``return 0''. (regsets_store_inferior_registers): Correct error message. Add missing ``return 0''. (linux_fetch_registers): Renamed from fetch_inferior_registers. (linux_store_registers): Renamed from store_inferior_registers. (linux_read_memory): Renamed from read_inferior_memory. (linux_write_memory): Renamed from write_inferior_memory. (linux_target_ops): New structure. (initialize_low): Call set_target_ops (). * gdbserver/remote-utils.c (unhexify): New function. (hexify): New function. (input_interrupt): Send signals to ``signal_pid''. * gdbserver/server.c (inferior_pid): Remove. (start_inferior): Update create_inferior call. (attach_inferior): Call add_inferior. (handle_query): New function. (main): Call handle_query for `q' packets. * gdbserver/server.h: Include "target.h". Remove obsolete prototypes. Add prototypes for "inferiors.c", "target.c", hexify, and unhexify.
2002-04-09 23:17:45 +02:00
gdbserver/linux-low: turn process/thread addition/deletion ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'new_process', 'delete_process', 'new_thread', 'delete_thread', and 'new_fork' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <add_linux_process> <add_lwp> <delete_lwp> <attach_lwp> <detach_one_lwp> <check_zombie_leaders> <filter_exit_event> <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. * linux-low.cc (delete_lwp): Turn into... (linux_process_target::delete_lwp): ...this. (linux_process_target::low_delete_thread): Define. (linux_add_process): Turn into... (linux_process_target::add_linux_process): ...this. (linux_process_target::low_new_process): Define. (linux_process_target::low_delete_process): Define. (linux_process_target::low_new_fork): Define. (add_lwp): Turn into... (linux_process_target::add_lwp): ...this. (linux_process_target::low_new_thread): Define. (linux_attach_lwp): Turn into... (linux_process_target::attach_lwp): ...this. (linux_detach_one_lwp): Turn into... (linux_process_target::detach_one_lwp): ...this. (linux_detach_lwp_callback): Remove and inline... (linux_process_target::detach): ...here. (check_zombie_leaders): Turn into... (linux_process_target::check_zombie_leaders): ...this. (filter_exit_event): Turn into... (linux_process_target::filter_exit_event): ...this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::create_inferior) (attach_proc_task_lwp_callback) (linux_process_target::attach) (linux_process_target::detach) (linux_process_target::mourn) * thread-db.cc (attach_thread) * linux-x86-low.cc (class x86_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (x86_linux_new_process): Turn into... (x86_target::low_new_process): ...this. (x86_linux_delete_process): Turn into... (x86_target::low_delete_process): ...this. (x86_target::low_new_thread): Define. (x86_target::low_delete_thread): Define. (x86_linux_new_fork): Turn into... (x86_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (aarch64_linux_new_process): Turn into... (aarch64_target::low_new_process): ...this. (aarch64_linux_delete_process): Turn into... (aarch64_target::low_delete_process): ...this. (aarch64_target::low_new_thread): Define. (aarch64_target::low_delete_thread): Define. (aarch64_linux_new_fork): Turn into... (aarch64_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (arm_new_process): Turn into... (arm_target::low_new_process): ...this. (arm_delete_process): Turn into... (arm_target::low_delete_process): ...this. (arm_new_thread): Turn into... (arm_target::low_new_thread): ...this. (arm_delete_thread): Turn into... (arm_target::low_delete_thread): ...this. (arm_new_fork): Turn into... (arm_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (mips_linux_new_process): Turn into... (mips_target::low_new_process): ...this. (mips_linux_delete_process): Turn into... (mips_target::low_delete_process): ...this. (mips_linux_new_thread): Turn into... (mips_target::low_new_thread): ...this. (mips_linux_delete_thread): Turn into... (mips_target::low_delete_thread): ...this. (mips_linux_new_fork): Turn into... (mips_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:28 +02:00
lwp_info *
linux_process_target::add_lwp (ptid_t ptid)
{
Rename "process" to "lwp" throughout. * linux-low.c (all_processes): Rename to... (all_lwps): ... this. (inferior_pid, handle_extended_wait, get_stop_pc): Adjust. (add_process): Rename to ... (add_lwp): ... this. Adjust. (linux_create_inferior): Adjust. (linux_attach_lwp): Adjust. (linux_attach): Adjust. (linux_kill_one_process): Rename to ... (linux_kill_one_lwp): ... this. Adjust. (linux_kill): Adjust. (linux_detach_one_process): Rename to ... (linux_detach_one_lwp): ... this. Adjust. (linux_detach): Adjust. (check_removed_breakpoint): Adjust. (status_pending_p): Adjust. (linux_wait_for_process): Rename to ... (linux_wait_for_lwp): ... this. Adjust. (linux_wait_for_event): Adjust. (send_sigstop): Adjust. (wait_for_sigstop): Adjust. (stop_all_processes): Rename to ... (stop_all_lwps): ... this. (linux_resume_one_process): Rename to ... (linux_resume_one_lwp): ... this. Adjust. (linux_set_resume_request, linux_continue_one_thread) (linux_queue_one_thread, resume_status_pending_p) (usr_store_inferior_registers, regsets_store_inferior_registers) (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Adjust. * linux-low.h (get_process): Rename to ... (get_lwp): ... this. Adjust. (get_thread_process): Rename to ... (get_thread_lwp): ... this. Adjust. (get_process_thread): Rename to ... (get_lwp_thread): ... this. Adjust. (struct process_info): Rename to ... (struct lwp_info): ... this. (all_processes): Rename to ... (all_lwps): ... this. * proc-service.c (ps_lgetregs): Adjust. * thread-db.c (thread_db_create_event, find_one_thread) (maybe_attach_thread, thread_db_get_tls_address): Adjust.
2009-03-17 21:25:35 +01:00
struct lwp_info *lwp;
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
gdbserver/linux-low: use std::list to store pending signals Use std::list to store pending signals instead of a manually-managed linked list. This is a refactoring. In the existing code, pending signals are kept in a manually-created linked list with "prev" pointers. A new pending signal is thus inserted to the beginning of the list. When consuming, GDB goes until the end of the list, following the "prev" pointers, and processes the final item. With this patch, a new item is added to the end of the list and the item at the front of the list is consumed. In other words, the list elements used to be stored in reverse order; with this patch, they are stored in their order of arrival. This causes a change in the debug messages that print the pending signals. Otherwise, no behavioral change is expected. gdbserver/ChangeLog: 2020-06-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Use std::list to stop pending signal instead of manually-created linked list. * linux-low.h: Include <list>. (struct pending_signal): Move here from linux-low.cc. (struct lwp_info) <pending_signals> <pending_signals_to_report>: Update the type. * linux-low.cc (struct pending_signals): Remove. (linux_process_target::delete_lwp) (linux_process_target::add_lwp) (enqueue_one_deferred_signal) (dequeue_one_deferred_signal) (enqueue_pending_signal) (linux_process_target::resume_one_lwp_throw) (linux_process_target::thread_needs_step_over) (linux_process_target::resume_one_thread) (linux_process_target::proceed_one_lwp): Update the use of pending signal list.
2020-06-22 14:13:48 +02:00
lwp = new lwp_info {};
Linux gdbserver confused when event randomization picks process exit event The tail end of linux_wait_1 isn't expecting that the select_event_lwp machinery can pick a whole-process exit event to report to GDB. When that happens, both gdb and gdbserver end up quite confused: ... (gdb) [Thread 24971.24971] #1 stopped. 0x0000003615a011f0 in ?? () c& Continuing. (gdb) [New Thread 24971.24981] [New Thread 24983.24983] [New Thread 24971.24982] [Thread 24983.24983] #3 stopped. 0x0000003615ebc7cc in __libc_fork () at ../nptl/sysdeps/unix/sysv/linux/fork.c:130 130 pid = ARCH_FORK (); [New Thread 24984.24984] Error in re-setting breakpoint -16: PC register is not available Error in re-setting breakpoint -17: PC register is not available Error in re-setting breakpoint -18: PC register is not available Error in re-setting breakpoint -19: PC register is not available Error in re-setting breakpoint -24: PC register is not available Error in re-setting breakpoint -25: PC register is not available Error in re-setting breakpoint -26: PC register is not available Error in re-setting breakpoint -27: PC register is not available Error in re-setting breakpoint -28: PC register is not available Error in re-setting breakpoint -29: PC register is not available Error in re-setting breakpoint -30: PC register is not available PC register is not available (gdb) gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (add_lwp): Set waitstatus to TARGET_WAITKIND_IGNORE. (linux_thread_alive): Use lwp_is_marked_dead. (extended_event_reported): Delete. (linux_wait_1): Check if waitstatus is TARGET_WAITKIND_IGNORE instead of extended_event_reported. (mark_lwp_dead): Don't set the 'dead' flag. Store the waitstatus as well. (lwp_is_marked_dead): New function. (lwp_running): Use lwp_is_marked_dead. * linux-low.h: Delete 'dead' field, and update 'waitstatus's comment.
2015-08-06 11:30:17 +02:00
lwp->waitstatus.kind = TARGET_WAITKIND_IGNORE;
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
AArch64: Racy: Don't set empty set of hardware BPs/WPs on new thread On some heavily loaded AArch64 boxes, GDB will sometimes hang forever when the inferior creates a thread. This hang happens inside the kernel during the ptrace call to set hardware watchpoints or hardware breakpoints. Currently, GDB will always set hw wp/bp at the start of each thread even if there are none set in the process. This patch works around the issue by avoiding setting hw wp/bp if there are none set for the process. On an effected machine, this fix drastically reduces the racy nature of the gdb.threads test set. I ran the entire gdb test suite across all processors for 100 iterations, then ran the results through the racy tests script. Without the patch, 58 .exp files in gdb.threads were marked as racy. After the patch this reduced to the same ~14 tests as the non effected boxes. Clearly GDB will still be subject to hangs on an effect box if hw wp/bp's are used prior to creating inferior threads on a heavily loaded system. To enable this in gdbserver, the sequence in gdbserver add_lwp() is switched to the same as gdb order as gdb, to ensure the thread is registered before calling new_thread(). This allows aarch64_linux_new_thread() to read the ptid. gdb/ChangeLog: * nat/aarch64-linux-hw-point.c (aarch64_linux_any_set_debug_regs_state): New function. * nat/aarch64-linux-hw-point.h (aarch64_linux_any_set_debug_regs_state): New declaration. * nat/aarch64-linux.c (aarch64_linux_new_thread): Check if any BPs or WPs are set. gdb/gdbserver/ChangeLog: * linux-low.c (add_lwp): Switch ordering.
2018-12-05 11:34:54 +01:00
lwp->thread = add_thread (ptid, lwp);
gdbserver/linux-low: turn process/thread addition/deletion ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'new_process', 'delete_process', 'new_thread', 'delete_thread', and 'new_fork' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <add_linux_process> <add_lwp> <delete_lwp> <attach_lwp> <detach_one_lwp> <check_zombie_leaders> <filter_exit_event> <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. * linux-low.cc (delete_lwp): Turn into... (linux_process_target::delete_lwp): ...this. (linux_process_target::low_delete_thread): Define. (linux_add_process): Turn into... (linux_process_target::add_linux_process): ...this. (linux_process_target::low_new_process): Define. (linux_process_target::low_delete_process): Define. (linux_process_target::low_new_fork): Define. (add_lwp): Turn into... (linux_process_target::add_lwp): ...this. (linux_process_target::low_new_thread): Define. (linux_attach_lwp): Turn into... (linux_process_target::attach_lwp): ...this. (linux_detach_one_lwp): Turn into... (linux_process_target::detach_one_lwp): ...this. (linux_detach_lwp_callback): Remove and inline... (linux_process_target::detach): ...here. (check_zombie_leaders): Turn into... (linux_process_target::check_zombie_leaders): ...this. (filter_exit_event): Turn into... (linux_process_target::filter_exit_event): ...this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::create_inferior) (attach_proc_task_lwp_callback) (linux_process_target::attach) (linux_process_target::detach) (linux_process_target::mourn) * thread-db.cc (attach_thread) * linux-x86-low.cc (class x86_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (x86_linux_new_process): Turn into... (x86_target::low_new_process): ...this. (x86_linux_delete_process): Turn into... (x86_target::low_delete_process): ...this. (x86_target::low_new_thread): Define. (x86_target::low_delete_thread): Define. (x86_linux_new_fork): Turn into... (x86_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (aarch64_linux_new_process): Turn into... (aarch64_target::low_new_process): ...this. (aarch64_linux_delete_process): Turn into... (aarch64_target::low_delete_process): ...this. (aarch64_target::low_new_thread): Define. (aarch64_target::low_delete_thread): Define. (aarch64_linux_new_fork): Turn into... (aarch64_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (arm_new_process): Turn into... (arm_target::low_new_process): ...this. (arm_delete_process): Turn into... (arm_target::low_delete_process): ...this. (arm_new_thread): Turn into... (arm_target::low_new_thread): ...this. (arm_delete_thread): Turn into... (arm_target::low_delete_thread): ...this. (arm_new_fork): Turn into... (arm_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (mips_linux_new_process): Turn into... (mips_target::low_new_process): ...this. (mips_linux_delete_process): Turn into... (mips_target::low_delete_process): ...this. (mips_linux_new_thread): Turn into... (mips_target::low_new_thread): ...this. (mips_linux_delete_thread): Turn into... (mips_target::low_delete_thread): ...this. (mips_linux_new_fork): Turn into... (mips_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:28 +02:00
low_new_thread (lwp);
Add h/w watchpoint support to x86-linux, win32-i386. * Makefile.in (SFILES): Add i386-low.c (i386_low_h): Define. (i386-low.o): Add dependencies. (linux-x86-low.o): Add i386-low.h dependency. (win32-i386-low.o): Ditto. * i386-low.c: New file. * i386-low.h: New file. * configure.srv (i[34567]86-*-cygwin*): Add i386-low.o to srv_tgtobj. (i[34567]86-*-linux*, i[34567]86-*-mingw*, x86_64-*-linux*): Ditto. * linux-low.c (linux_add_process): Initialize arch_private. (linux_remove_process): Free arch_private. (add_lwp): Initialize arch_private. (delete_lwp): Free arch_private. (linux_resume_one_lwp): Call the_low_target.prepare_to_resume if provided. * linux-low.h (process_info_private): New member arch_private. (lwp_info): New member arch_private. (linux_target_ops): New members new_process, new_thread, prepare_to_resume. (ptid_of): New macro. * linux-x86-low.c: Include stddef.h, i386-low.h. (arch_process_info): New struct. (arch_lwp_info): New struct. (x86_linux_dr_get, x86_linux_dr_set): New functions. (i386_dr_low_set_addr, i386_dr_low_set_control): New functions. (i386_dr_low_get_status): New function. (x86_insert_point, x86_remove_point): New functions. (x86_stopped_by_watchpoint): New function. (x86_stopped_data_address): New function. (x86_linux_new_process, x86_linux_new_thread): New functions. (x86_linux_prepare_to_resume): New function. (the_low_target): Add entries for insert_point, remove_point, stopped_by_watchpoint, stopped_data_address, new_process, new_thread, prepare_to_resume. * server.c (debug_hw_points): New global. (monitor_show_help): Document set debug-hw-points. (handle_query): Process "set debug-hw-points". * server.h (debug_hw_points): Declare. (paddress): Declare. * utils.c (NUMCELLS, CELLSIZE): New macros. (get_sell, xsnprintf, paddress): New functions. * win32-arm-low.c (the_low_target): Add entries for insert_point, remove_point, stopped_by_watchpoint, stopped_data_address. * win32-i386-low.c: Include i386-low.h. (debug_reg_state): Replaces dr. (i386_dr_low_set_addr, i386_dr_low_set_control): New functions. (i386_dr_low_get_status): New function. (i386_insert_point, i386_remove_point): New functions. (i386_stopped_by_watchpoint): New function. (i386_stopped_data_address): New function. (i386_initial_stuff): Update. (get_thread_context,set_thread_context,i386_thread_added): Update. (the_low_target): Add entries for insert_point, remove_point, stopped_by_watchpoint, stopped_data_address. * win32-low.c (win32_insert_watchpoint): New function. (win32_remove_watchpoint): New function. (win32_stopped_by_watchpoint): New function. (win32_stopped_data_address): New function. (win32_target_ops): Add entries for insert_watchpoint, remove_watchpoint, stopped_by_watchpoint, stopped_data_address. * win32-low.h (win32_target_ops): New members insert_point, remove_point, stopped_by_watchpoint, stopped_data_address.
2009-06-30 18:35:25 +02:00
Rename "process" to "lwp" throughout. * linux-low.c (all_processes): Rename to... (all_lwps): ... this. (inferior_pid, handle_extended_wait, get_stop_pc): Adjust. (add_process): Rename to ... (add_lwp): ... this. Adjust. (linux_create_inferior): Adjust. (linux_attach_lwp): Adjust. (linux_attach): Adjust. (linux_kill_one_process): Rename to ... (linux_kill_one_lwp): ... this. Adjust. (linux_kill): Adjust. (linux_detach_one_process): Rename to ... (linux_detach_one_lwp): ... this. Adjust. (linux_detach): Adjust. (check_removed_breakpoint): Adjust. (status_pending_p): Adjust. (linux_wait_for_process): Rename to ... (linux_wait_for_lwp): ... this. Adjust. (linux_wait_for_event): Adjust. (send_sigstop): Adjust. (wait_for_sigstop): Adjust. (stop_all_processes): Rename to ... (stop_all_lwps): ... this. (linux_resume_one_process): Rename to ... (linux_resume_one_lwp): ... this. Adjust. (linux_set_resume_request, linux_continue_one_thread) (linux_queue_one_thread, resume_status_pending_p) (usr_store_inferior_registers, regsets_store_inferior_registers) (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Adjust. * linux-low.h (get_process): Rename to ... (get_lwp): ... this. Adjust. (get_thread_process): Rename to ... (get_thread_lwp): ... this. Adjust. (get_process_thread): Rename to ... (get_lwp_thread): ... this. Adjust. (struct process_info): Rename to ... (struct lwp_info): ... this. (all_processes): Rename to ... (all_lwps): ... this. * proc-service.c (ps_lgetregs): Adjust. * thread-db.c (thread_db_create_event, find_one_thread) (maybe_attach_thread, thread_db_get_tls_address): Adjust.
2009-03-17 21:25:35 +01:00
return lwp;
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
}
gdbserver/linux-low: turn process/thread addition/deletion ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'new_process', 'delete_process', 'new_thread', 'delete_thread', and 'new_fork' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <add_linux_process> <add_lwp> <delete_lwp> <attach_lwp> <detach_one_lwp> <check_zombie_leaders> <filter_exit_event> <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. * linux-low.cc (delete_lwp): Turn into... (linux_process_target::delete_lwp): ...this. (linux_process_target::low_delete_thread): Define. (linux_add_process): Turn into... (linux_process_target::add_linux_process): ...this. (linux_process_target::low_new_process): Define. (linux_process_target::low_delete_process): Define. (linux_process_target::low_new_fork): Define. (add_lwp): Turn into... (linux_process_target::add_lwp): ...this. (linux_process_target::low_new_thread): Define. (linux_attach_lwp): Turn into... (linux_process_target::attach_lwp): ...this. (linux_detach_one_lwp): Turn into... (linux_process_target::detach_one_lwp): ...this. (linux_detach_lwp_callback): Remove and inline... (linux_process_target::detach): ...here. (check_zombie_leaders): Turn into... (linux_process_target::check_zombie_leaders): ...this. (filter_exit_event): Turn into... (linux_process_target::filter_exit_event): ...this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::create_inferior) (attach_proc_task_lwp_callback) (linux_process_target::attach) (linux_process_target::detach) (linux_process_target::mourn) * thread-db.cc (attach_thread) * linux-x86-low.cc (class x86_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (x86_linux_new_process): Turn into... (x86_target::low_new_process): ...this. (x86_linux_delete_process): Turn into... (x86_target::low_delete_process): ...this. (x86_target::low_new_thread): Define. (x86_target::low_delete_thread): Define. (x86_linux_new_fork): Turn into... (x86_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (aarch64_linux_new_process): Turn into... (aarch64_target::low_new_process): ...this. (aarch64_linux_delete_process): Turn into... (aarch64_target::low_delete_process): ...this. (aarch64_target::low_new_thread): Define. (aarch64_target::low_delete_thread): Define. (aarch64_linux_new_fork): Turn into... (aarch64_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (arm_new_process): Turn into... (arm_target::low_new_process): ...this. (arm_delete_process): Turn into... (arm_target::low_delete_process): ...this. (arm_new_thread): Turn into... (arm_target::low_new_thread): ...this. (arm_delete_thread): Turn into... (arm_target::low_delete_thread): ...this. (arm_new_fork): Turn into... (arm_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (mips_linux_new_process): Turn into... (mips_target::low_new_process): ...this. (mips_linux_delete_process): Turn into... (mips_target::low_delete_process): ...this. (mips_linux_new_thread): Turn into... (mips_target::low_new_thread): ...this. (mips_linux_delete_thread): Turn into... (mips_target::low_delete_thread): ...this. (mips_linux_new_fork): Turn into... (mips_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:28 +02:00
void
linux_process_target::low_new_thread (lwp_info *info)
{
/* Nop. */
}
Share fork_inferior et al with gdbserver This is the most important (and the biggest, sorry) patch of the series. It moves fork_inferior from gdb/fork-child.c to nat/fork-inferior.c and makes all the necessary adjustments to both GDB and gdbserver to make sure everything works OK. There is no "most important change" with this patch; all changes are made in a progressive way, making sure that gdbserver had the necessary features while not breaking GDB at the same time. I decided to go ahead and implement a partial support for starting the inferior with a shell on gdbserver, although the full feature comes in the next patch. The user won't have the option to disable the startup-with-shell, and also won't be able to change which shell gdbserver will use (other than setting the $SHELL environment variable, that is). Everything is working as expected, and no regressions were present during the tests. gdb/ChangeLog: 2017-06-07 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> * Makefile.in (HFILES_NO_SRCDIR): Add "common/common-inferior.h" and "nat/fork-inferior.h". * common/common-inferior.h: New file, with contents from "gdb/inferior.h". * commom/common-utils.c: Include "common-utils.h". (stringify_argv): New function. * common/common-utils.h (stringify_argv): New prototype. * configure.nat: Add "fork-inferior.o" as a dependency for "*linux*", "fbsd*" and "nbsd*" hosts. * corefile.c (get_exec_file): Update comment. * darwin-nat.c (darwin_ptrace_him): Call "gdb_startup_inferior" instead of "startup_inferior". (darwin_create_inferior): Call "add_thread_silent" after "fork_inferior". * fork-child.c: Cleanup unnecessary includes. (SHELL_FILE): Move to "common/common-fork-child.c". (environ): Likewise. (exec_wrapper): Initialize. (get_exec_wrapper): New function. (breakup_args): Move to "common/common-fork-child.c"; rename to "breakup_args_for_exec". (escape_bang_in_quoted_argument): Move to "common/common-fork-child.c". (saved_ui): New variable. (prefork_hook): New function. (postfork_hook): Likewise. (postfork_child_hook): Likewise. (gdb_startup_inferior): Likewise. (fork_inferior): Move to "common/common-fork-child.c". Update function to support gdbserver. (startup_inferior): Likewise. * gdbcore.h (get_exec_file): Remove declaration. * gnu-nat.c (gnu_create_inferior): Call "gdb_startup_inferior" instead of "startup_inferior". Call "add_thread_silent" after "fork_inferior". * inf-ptrace.c: Include "nat/fork-inferior.h" and "utils.h". (inf_ptrace_create_inferior): Call "gdb_startup_inferior" instead of "startup_inferior". Call "add_thread_silent" after "fork_inferior". * inferior.h: Include "common-inferior.h". (trace_start_error): Move to "common/common-utils.h". (trace_start_error_with_name): Likewise. (fork_inferior): Move prototype to "nat/fork-inferior.h". (startup_inferior): Likewise. (gdb_startup_inferior): New prototype. * nat/fork-inferior.c: New file, with contents from "fork-child.c". * nat/fork-inferior.h: New file. * procfs.c (procfs_init_inferior): Call "gdb_startup_inferior" instead of "startup_inferior". Call "add_thread_silent" after "fork_inferior". * target.h (target_terminal_init): Move prototype to "target/target.h". (target_terminal_inferior): Likewise. (target_terminal_ours): Likewise. * target/target.h (target_terminal_init): New prototype, moved from "target.h". (target_terminal_inferior): Likewise. (target_terminal_ours): Likewise. * utils.c (gdb_flush_out_err): New function. gdb/gdbserver/ChangeLog: 2017-06-07 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> * Makefile.in (SFILES): Add "nat/fork-inferior.o". * configure: Regenerate. * configure.srv (srv_linux_obj): Add "fork-child.o" and "fork-inferior.o". (i[34567]86-*-lynxos*): Likewise. (spu*-*-*): Likewise. * fork-child.c: New file. * linux-low.c: Include "common-inferior.h", "nat/fork-inferior.h" and "environ.h". (linux_ptrace_fun): New function. (linux_create_inferior): Adjust function prototype to reflect change on "target.h". Adjust function code to use "fork_inferior". (linux_request_interrupt): Delete "signal_pid". * lynx-low.c: Include "common-inferior.h" and "nat/fork-inferior.h". (lynx_ptrace_fun): New function. (lynx_create_inferior): Adjust function prototype to reflect change on "target.h". Adjust function code to use "fork_inferior". * nto-low.c (nto_create_inferior): Adjust function prototype and code to reflect change on "target.h". Update comments. * server.c: Include "common-inferior.h", "nat/fork-inferior.h", "common-terminal.h" and "environ.h". (terminal_fd): Moved to fork-child.c. (old_foreground_pgrp): Likewise. (restore_old_foreground_pgrp): Likewise. (last_status): Make it global. (last_ptid): Likewise. (our_environ): New variable. (startup_with_shell): Likewise. (program_name): Likewise. (program_argv): Rename to... (program_args): ...this. (wrapper_argv): New variable. (start_inferior): Delete function. (get_exec_wrapper): New function. (get_exec_file): Likewise. (get_environ): Likewise. (prefork_hook): Likewise. (post_fork_inferior): Likewise. (postfork_hook): Likewise. (postfork_child_hook): Likewise. (handle_v_run): Update code to deal with arguments coming from the remote host. Update calls from "start_inferior" to "create_inferior". (captured_main): Likewise. Initialize environment variable. Call "have_job_control". * server.h (post_fork_inferior): New prototype. (get_environ): Likewise. (last_status): Declare. (last_ptid): Likewise. (signal_pid): Likewise. * spu-low.c: Include "common-inferior.h" and "nat/fork-inferior.h". (spu_ptrace_fun): New function. (spu_create_inferior): Adjust function prototype to reflect change on "target.h". Adjust function code to use "fork_inferior". * target.c (target_terminal_init): New function. (target_terminal_inferior): Likewise. (target_terminal_ours): Likewise. * target.h: Include <vector>. (struct target_ops) <create_inferior>: Update prototype. (create_inferior): Update macro. * utils.c (gdb_flush_out_err): New function. * win32-low.c (win32_create_inferior): Adjust function prototype and code to reflect change on "target.h". gdb/testsuite/ChangeLog: 2017-06-07 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.server/non-existing-program.exp: Update regex in order to reflect the fact that gdbserver is now using fork_inferior (with a shell) to startup the inferior.
2016-12-23 03:11:11 +01:00
/* Callback to be used when calling fork_inferior, responsible for
actually initiating the tracing of the inferior. */
static void
linux_ptrace_fun ()
{
if (ptrace (PTRACE_TRACEME, 0, (PTRACE_TYPE_ARG3) 0,
(PTRACE_TYPE_ARG4) 0) < 0)
trace_start_error_with_name ("ptrace");
Share fork_inferior et al with gdbserver This is the most important (and the biggest, sorry) patch of the series. It moves fork_inferior from gdb/fork-child.c to nat/fork-inferior.c and makes all the necessary adjustments to both GDB and gdbserver to make sure everything works OK. There is no "most important change" with this patch; all changes are made in a progressive way, making sure that gdbserver had the necessary features while not breaking GDB at the same time. I decided to go ahead and implement a partial support for starting the inferior with a shell on gdbserver, although the full feature comes in the next patch. The user won't have the option to disable the startup-with-shell, and also won't be able to change which shell gdbserver will use (other than setting the $SHELL environment variable, that is). Everything is working as expected, and no regressions were present during the tests. gdb/ChangeLog: 2017-06-07 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> * Makefile.in (HFILES_NO_SRCDIR): Add "common/common-inferior.h" and "nat/fork-inferior.h". * common/common-inferior.h: New file, with contents from "gdb/inferior.h". * commom/common-utils.c: Include "common-utils.h". (stringify_argv): New function. * common/common-utils.h (stringify_argv): New prototype. * configure.nat: Add "fork-inferior.o" as a dependency for "*linux*", "fbsd*" and "nbsd*" hosts. * corefile.c (get_exec_file): Update comment. * darwin-nat.c (darwin_ptrace_him): Call "gdb_startup_inferior" instead of "startup_inferior". (darwin_create_inferior): Call "add_thread_silent" after "fork_inferior". * fork-child.c: Cleanup unnecessary includes. (SHELL_FILE): Move to "common/common-fork-child.c". (environ): Likewise. (exec_wrapper): Initialize. (get_exec_wrapper): New function. (breakup_args): Move to "common/common-fork-child.c"; rename to "breakup_args_for_exec". (escape_bang_in_quoted_argument): Move to "common/common-fork-child.c". (saved_ui): New variable. (prefork_hook): New function. (postfork_hook): Likewise. (postfork_child_hook): Likewise. (gdb_startup_inferior): Likewise. (fork_inferior): Move to "common/common-fork-child.c". Update function to support gdbserver. (startup_inferior): Likewise. * gdbcore.h (get_exec_file): Remove declaration. * gnu-nat.c (gnu_create_inferior): Call "gdb_startup_inferior" instead of "startup_inferior". Call "add_thread_silent" after "fork_inferior". * inf-ptrace.c: Include "nat/fork-inferior.h" and "utils.h". (inf_ptrace_create_inferior): Call "gdb_startup_inferior" instead of "startup_inferior". Call "add_thread_silent" after "fork_inferior". * inferior.h: Include "common-inferior.h". (trace_start_error): Move to "common/common-utils.h". (trace_start_error_with_name): Likewise. (fork_inferior): Move prototype to "nat/fork-inferior.h". (startup_inferior): Likewise. (gdb_startup_inferior): New prototype. * nat/fork-inferior.c: New file, with contents from "fork-child.c". * nat/fork-inferior.h: New file. * procfs.c (procfs_init_inferior): Call "gdb_startup_inferior" instead of "startup_inferior". Call "add_thread_silent" after "fork_inferior". * target.h (target_terminal_init): Move prototype to "target/target.h". (target_terminal_inferior): Likewise. (target_terminal_ours): Likewise. * target/target.h (target_terminal_init): New prototype, moved from "target.h". (target_terminal_inferior): Likewise. (target_terminal_ours): Likewise. * utils.c (gdb_flush_out_err): New function. gdb/gdbserver/ChangeLog: 2017-06-07 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> * Makefile.in (SFILES): Add "nat/fork-inferior.o". * configure: Regenerate. * configure.srv (srv_linux_obj): Add "fork-child.o" and "fork-inferior.o". (i[34567]86-*-lynxos*): Likewise. (spu*-*-*): Likewise. * fork-child.c: New file. * linux-low.c: Include "common-inferior.h", "nat/fork-inferior.h" and "environ.h". (linux_ptrace_fun): New function. (linux_create_inferior): Adjust function prototype to reflect change on "target.h". Adjust function code to use "fork_inferior". (linux_request_interrupt): Delete "signal_pid". * lynx-low.c: Include "common-inferior.h" and "nat/fork-inferior.h". (lynx_ptrace_fun): New function. (lynx_create_inferior): Adjust function prototype to reflect change on "target.h". Adjust function code to use "fork_inferior". * nto-low.c (nto_create_inferior): Adjust function prototype and code to reflect change on "target.h". Update comments. * server.c: Include "common-inferior.h", "nat/fork-inferior.h", "common-terminal.h" and "environ.h". (terminal_fd): Moved to fork-child.c. (old_foreground_pgrp): Likewise. (restore_old_foreground_pgrp): Likewise. (last_status): Make it global. (last_ptid): Likewise. (our_environ): New variable. (startup_with_shell): Likewise. (program_name): Likewise. (program_argv): Rename to... (program_args): ...this. (wrapper_argv): New variable. (start_inferior): Delete function. (get_exec_wrapper): New function. (get_exec_file): Likewise. (get_environ): Likewise. (prefork_hook): Likewise. (post_fork_inferior): Likewise. (postfork_hook): Likewise. (postfork_child_hook): Likewise. (handle_v_run): Update code to deal with arguments coming from the remote host. Update calls from "start_inferior" to "create_inferior". (captured_main): Likewise. Initialize environment variable. Call "have_job_control". * server.h (post_fork_inferior): New prototype. (get_environ): Likewise. (last_status): Declare. (last_ptid): Likewise. (signal_pid): Likewise. * spu-low.c: Include "common-inferior.h" and "nat/fork-inferior.h". (spu_ptrace_fun): New function. (spu_create_inferior): Adjust function prototype to reflect change on "target.h". Adjust function code to use "fork_inferior". * target.c (target_terminal_init): New function. (target_terminal_inferior): Likewise. (target_terminal_ours): Likewise. * target.h: Include <vector>. (struct target_ops) <create_inferior>: Update prototype. (create_inferior): Update macro. * utils.c (gdb_flush_out_err): New function. * win32-low.c (win32_create_inferior): Adjust function prototype and code to reflect change on "target.h". gdb/testsuite/ChangeLog: 2017-06-07 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.server/non-existing-program.exp: Update regex in order to reflect the fact that gdbserver is now using fork_inferior (with a shell) to startup the inferior.
2016-12-23 03:11:11 +01:00
if (setpgid (0, 0) < 0)
trace_start_error_with_name ("setpgid");
/* If GDBserver is connected to gdb via stdio, redirect the inferior's
stdout to stderr so that inferior i/o doesn't corrupt the connection.
Also, redirect stdin to /dev/null. */
if (remote_connection_is_stdio ())
{
if (close (0) < 0)
trace_start_error_with_name ("close");
if (open ("/dev/null", O_RDONLY) < 0)
trace_start_error_with_name ("open");
if (dup2 (2, 1) < 0)
trace_start_error_with_name ("dup2");
if (write (2, "stdin/stdout redirected\n",
sizeof ("stdin/stdout redirected\n") - 1) < 0)
{
/* Errors ignored. */;
}
}
}
/* Start an inferior process and returns its pid.
Share fork_inferior et al with gdbserver This is the most important (and the biggest, sorry) patch of the series. It moves fork_inferior from gdb/fork-child.c to nat/fork-inferior.c and makes all the necessary adjustments to both GDB and gdbserver to make sure everything works OK. There is no "most important change" with this patch; all changes are made in a progressive way, making sure that gdbserver had the necessary features while not breaking GDB at the same time. I decided to go ahead and implement a partial support for starting the inferior with a shell on gdbserver, although the full feature comes in the next patch. The user won't have the option to disable the startup-with-shell, and also won't be able to change which shell gdbserver will use (other than setting the $SHELL environment variable, that is). Everything is working as expected, and no regressions were present during the tests. gdb/ChangeLog: 2017-06-07 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> * Makefile.in (HFILES_NO_SRCDIR): Add "common/common-inferior.h" and "nat/fork-inferior.h". * common/common-inferior.h: New file, with contents from "gdb/inferior.h". * commom/common-utils.c: Include "common-utils.h". (stringify_argv): New function. * common/common-utils.h (stringify_argv): New prototype. * configure.nat: Add "fork-inferior.o" as a dependency for "*linux*", "fbsd*" and "nbsd*" hosts. * corefile.c (get_exec_file): Update comment. * darwin-nat.c (darwin_ptrace_him): Call "gdb_startup_inferior" instead of "startup_inferior". (darwin_create_inferior): Call "add_thread_silent" after "fork_inferior". * fork-child.c: Cleanup unnecessary includes. (SHELL_FILE): Move to "common/common-fork-child.c". (environ): Likewise. (exec_wrapper): Initialize. (get_exec_wrapper): New function. (breakup_args): Move to "common/common-fork-child.c"; rename to "breakup_args_for_exec". (escape_bang_in_quoted_argument): Move to "common/common-fork-child.c". (saved_ui): New variable. (prefork_hook): New function. (postfork_hook): Likewise. (postfork_child_hook): Likewise. (gdb_startup_inferior): Likewise. (fork_inferior): Move to "common/common-fork-child.c". Update function to support gdbserver. (startup_inferior): Likewise. * gdbcore.h (get_exec_file): Remove declaration. * gnu-nat.c (gnu_create_inferior): Call "gdb_startup_inferior" instead of "startup_inferior". Call "add_thread_silent" after "fork_inferior". * inf-ptrace.c: Include "nat/fork-inferior.h" and "utils.h". (inf_ptrace_create_inferior): Call "gdb_startup_inferior" instead of "startup_inferior". Call "add_thread_silent" after "fork_inferior". * inferior.h: Include "common-inferior.h". (trace_start_error): Move to "common/common-utils.h". (trace_start_error_with_name): Likewise. (fork_inferior): Move prototype to "nat/fork-inferior.h". (startup_inferior): Likewise. (gdb_startup_inferior): New prototype. * nat/fork-inferior.c: New file, with contents from "fork-child.c". * nat/fork-inferior.h: New file. * procfs.c (procfs_init_inferior): Call "gdb_startup_inferior" instead of "startup_inferior". Call "add_thread_silent" after "fork_inferior". * target.h (target_terminal_init): Move prototype to "target/target.h". (target_terminal_inferior): Likewise. (target_terminal_ours): Likewise. * target/target.h (target_terminal_init): New prototype, moved from "target.h". (target_terminal_inferior): Likewise. (target_terminal_ours): Likewise. * utils.c (gdb_flush_out_err): New function. gdb/gdbserver/ChangeLog: 2017-06-07 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> * Makefile.in (SFILES): Add "nat/fork-inferior.o". * configure: Regenerate. * configure.srv (srv_linux_obj): Add "fork-child.o" and "fork-inferior.o". (i[34567]86-*-lynxos*): Likewise. (spu*-*-*): Likewise. * fork-child.c: New file. * linux-low.c: Include "common-inferior.h", "nat/fork-inferior.h" and "environ.h". (linux_ptrace_fun): New function. (linux_create_inferior): Adjust function prototype to reflect change on "target.h". Adjust function code to use "fork_inferior". (linux_request_interrupt): Delete "signal_pid". * lynx-low.c: Include "common-inferior.h" and "nat/fork-inferior.h". (lynx_ptrace_fun): New function. (lynx_create_inferior): Adjust function prototype to reflect change on "target.h". Adjust function code to use "fork_inferior". * nto-low.c (nto_create_inferior): Adjust function prototype and code to reflect change on "target.h". Update comments. * server.c: Include "common-inferior.h", "nat/fork-inferior.h", "common-terminal.h" and "environ.h". (terminal_fd): Moved to fork-child.c. (old_foreground_pgrp): Likewise. (restore_old_foreground_pgrp): Likewise. (last_status): Make it global. (last_ptid): Likewise. (our_environ): New variable. (startup_with_shell): Likewise. (program_name): Likewise. (program_argv): Rename to... (program_args): ...this. (wrapper_argv): New variable. (start_inferior): Delete function. (get_exec_wrapper): New function. (get_exec_file): Likewise. (get_environ): Likewise. (prefork_hook): Likewise. (post_fork_inferior): Likewise. (postfork_hook): Likewise. (postfork_child_hook): Likewise. (handle_v_run): Update code to deal with arguments coming from the remote host. Update calls from "start_inferior" to "create_inferior". (captured_main): Likewise. Initialize environment variable. Call "have_job_control". * server.h (post_fork_inferior): New prototype. (get_environ): Likewise. (last_status): Declare. (last_ptid): Likewise. (signal_pid): Likewise. * spu-low.c: Include "common-inferior.h" and "nat/fork-inferior.h". (spu_ptrace_fun): New function. (spu_create_inferior): Adjust function prototype to reflect change on "target.h". Adjust function code to use "fork_inferior". * target.c (target_terminal_init): New function. (target_terminal_inferior): Likewise. (target_terminal_ours): Likewise. * target.h: Include <vector>. (struct target_ops) <create_inferior>: Update prototype. (create_inferior): Update macro. * utils.c (gdb_flush_out_err): New function. * win32-low.c (win32_create_inferior): Adjust function prototype and code to reflect change on "target.h". gdb/testsuite/ChangeLog: 2017-06-07 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.server/non-existing-program.exp: Update regex in order to reflect the fact that gdbserver is now using fork_inferior (with a shell) to startup the inferior.
2016-12-23 03:11:11 +01:00
PROGRAM is the name of the program to be started, and PROGRAM_ARGS
are its arguments. */
int
linux_process_target::create_inferior (const char *program,
const std::vector<char *> &program_args)
{
client_state &cs = get_client_state ();
struct lwp_info *new_lwp;
int pid;
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
ptid_t ptid;
* inferior.h (disable_randomization): Declare. * infrun.c (disable_randomization): New global variable. (show_disable_randomization): New function. (set_disable_randomization): Likewise. (_initialize_infrun): Install set/show disable-randomization commands. * linux-nat.c (disable_randomization): Remove. (show_disable_randomization): Likewise. (set_disable_randomization): Likewise. (_initialize_linux_nat): No longer install set/show disable-randomization commands here. (linux_nat_supports_disable_randomization): New function. (linux_nat_add_target): Install it. * remote.c (PACKET_QDisableRandomization): New enum value. (remote_protocol_packets): Support QDisableRandomization. (_initialize_remote): Likewise. (remote_supports_disable_randomization): New function. (init_remote_ops): Install it. (extended_remote_supports_disable_randomization): New function. (init_extended_remote_ops): Install it. (extended_remote_disable_randomization): New function. (extended_remote_create_inferior_1): Call it. * target.h (struct target_ops): Add to_supports_disable_randomization. (target_supports_disable_randomization): Add prototype. * target.c (target_supports_disable_randomization): New function. (find_default_supports_disable_randomization): Likewise. (init_dummy_target): Install it. doc/ * gdb.texinfo (Starting your Program): "set disable-randomization" is no longer Linux-specific. (Remote Configuration): Document "set remote disable-randomization-packet". (General Query Packets): Document "QDisableRandomization" packet and add it to "qSupported" list. gdbserver/ * configure.ac: Check support for personality routine. * configure: Regenerate. * config.in: Likewise. * linux-low.c: Include <sys/personality.h>. Define ADDR_NO_RANDOMIZE if necessary. (linux_create_inferior): Disable address space randomization when forking inferior, if requested. (linux_supports_disable_randomization): New function. (linux_target_ops): Install it. * server.h (disable_randomization): Declare. * server.c (disable_randomization): New global variable. (handle_general_set): Handle QDisableRandomization. (handle_query): Likewise for qSupported. (main): Support --disable-randomization and --no-disable-randomization command line arguments. * target.h (struct target_ops): Add supports_disable_randomization. (target_supports_disable_randomization): New macro.
2011-10-07 14:06:48 +02:00
{
maybe_disable_address_space_randomization restore_personality
(cs.disable_randomization);
Use construct_inferior_arguments which handles special chars Use the construct_inferior_arguments function instead of stringify_argv to construct a string from the program arguments in those places where that one is then passed to fork_inferior (linux-low, lyn-low), since construct_inferior_arguments properly takes care of special characters, while stringify_argv does not. Using construct_inferior_arguments seems "natural", since its documentation also mentions that it "does the same shell processing as fork_inferior". Since construct_inferior_args has been extended to do proper quoting for Windows shells in commit 5d60742e2dd3c9b475dce54b56043a358751bbb8 ("Fix quoting of special characters for the MinGW build.", 2012-06-12), use it for the Windows case as well. (I could not test that case myself, though.) Adapt handling of empty args in function 'handle_v_run' in gdbserver/server.cc to just insert an empty string for an empty arg, since that one is now properly handled in 'construct_inferior_arguments' already (and inserting a "''" string in 'handle_v_run' would otherwise cause that one to be treated as a string literally containing two quote characters, which 'construct_inferior_args' would preserve by adding extra escaping). This makes gdbserver properly handle program args containing special characters (like spaces), e.g. (example from PR25893) $ gdbserver localhost:50505 myprogram "hello world" now properly handles "hello world" as a single arg, not two separate ones ("hello", "world"). gdbserver/ChangeLog: PR gdbserver/25893 * linux-low.cc (linux_process_target::create_inferior), lynx-low.cc (lynx_process_target::create_inferior), win32-low.cc (win32_process_target::create_inferior): Use construct_inferior_arguments instead of stringify_argv to get string representation which properly escapes special characters. * server.cc (handle_v_run): Just pass empty program arg as such, since any further processing is now handled via construct_inferior_arguments. Change-Id: Ibf963fcd51415c948840fb463289516b3479b0c3
2020-05-25 17:39:43 +02:00
std::string str_program_args = construct_inferior_arguments (program_args);
pid = fork_inferior (program,
str_program_args.c_str (),
get_environ ()->envp (), linux_ptrace_fun,
NULL, NULL, NULL, NULL);
}
* inferior.h (disable_randomization): Declare. * infrun.c (disable_randomization): New global variable. (show_disable_randomization): New function. (set_disable_randomization): Likewise. (_initialize_infrun): Install set/show disable-randomization commands. * linux-nat.c (disable_randomization): Remove. (show_disable_randomization): Likewise. (set_disable_randomization): Likewise. (_initialize_linux_nat): No longer install set/show disable-randomization commands here. (linux_nat_supports_disable_randomization): New function. (linux_nat_add_target): Install it. * remote.c (PACKET_QDisableRandomization): New enum value. (remote_protocol_packets): Support QDisableRandomization. (_initialize_remote): Likewise. (remote_supports_disable_randomization): New function. (init_remote_ops): Install it. (extended_remote_supports_disable_randomization): New function. (init_extended_remote_ops): Install it. (extended_remote_disable_randomization): New function. (extended_remote_create_inferior_1): Call it. * target.h (struct target_ops): Add to_supports_disable_randomization. (target_supports_disable_randomization): Add prototype. * target.c (target_supports_disable_randomization): New function. (find_default_supports_disable_randomization): Likewise. (init_dummy_target): Install it. doc/ * gdb.texinfo (Starting your Program): "set disable-randomization" is no longer Linux-specific. (Remote Configuration): Document "set remote disable-randomization-packet". (General Query Packets): Document "QDisableRandomization" packet and add it to "qSupported" list. gdbserver/ * configure.ac: Check support for personality routine. * configure: Regenerate. * config.in: Likewise. * linux-low.c: Include <sys/personality.h>. Define ADDR_NO_RANDOMIZE if necessary. (linux_create_inferior): Disable address space randomization when forking inferior, if requested. (linux_supports_disable_randomization): New function. (linux_target_ops): Install it. * server.h (disable_randomization): Declare. * server.c (disable_randomization): New global variable. (handle_general_set): Handle QDisableRandomization. (handle_query): Likewise for qSupported. (main): Support --disable-randomization and --no-disable-randomization command line arguments. * target.h (struct target_ops): Add supports_disable_randomization. (target_supports_disable_randomization): New macro.
2011-10-07 14:06:48 +02:00
gdbserver/linux-low: turn process/thread addition/deletion ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'new_process', 'delete_process', 'new_thread', 'delete_thread', and 'new_fork' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <add_linux_process> <add_lwp> <delete_lwp> <attach_lwp> <detach_one_lwp> <check_zombie_leaders> <filter_exit_event> <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. * linux-low.cc (delete_lwp): Turn into... (linux_process_target::delete_lwp): ...this. (linux_process_target::low_delete_thread): Define. (linux_add_process): Turn into... (linux_process_target::add_linux_process): ...this. (linux_process_target::low_new_process): Define. (linux_process_target::low_delete_process): Define. (linux_process_target::low_new_fork): Define. (add_lwp): Turn into... (linux_process_target::add_lwp): ...this. (linux_process_target::low_new_thread): Define. (linux_attach_lwp): Turn into... (linux_process_target::attach_lwp): ...this. (linux_detach_one_lwp): Turn into... (linux_process_target::detach_one_lwp): ...this. (linux_detach_lwp_callback): Remove and inline... (linux_process_target::detach): ...here. (check_zombie_leaders): Turn into... (linux_process_target::check_zombie_leaders): ...this. (filter_exit_event): Turn into... (linux_process_target::filter_exit_event): ...this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::create_inferior) (attach_proc_task_lwp_callback) (linux_process_target::attach) (linux_process_target::detach) (linux_process_target::mourn) * thread-db.cc (attach_thread) * linux-x86-low.cc (class x86_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (x86_linux_new_process): Turn into... (x86_target::low_new_process): ...this. (x86_linux_delete_process): Turn into... (x86_target::low_delete_process): ...this. (x86_target::low_new_thread): Define. (x86_target::low_delete_thread): Define. (x86_linux_new_fork): Turn into... (x86_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (aarch64_linux_new_process): Turn into... (aarch64_target::low_new_process): ...this. (aarch64_linux_delete_process): Turn into... (aarch64_target::low_delete_process): ...this. (aarch64_target::low_new_thread): Define. (aarch64_target::low_delete_thread): Define. (aarch64_linux_new_fork): Turn into... (aarch64_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (arm_new_process): Turn into... (arm_target::low_new_process): ...this. (arm_delete_process): Turn into... (arm_target::low_delete_process): ...this. (arm_new_thread): Turn into... (arm_target::low_new_thread): ...this. (arm_delete_thread): Turn into... (arm_target::low_delete_thread): ...this. (arm_new_fork): Turn into... (arm_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (mips_linux_new_process): Turn into... (mips_target::low_new_process): ...this. (mips_linux_delete_process): Turn into... (mips_target::low_delete_process): ...this. (mips_linux_new_thread): Turn into... (mips_target::low_new_thread): ...this. (mips_linux_delete_thread): Turn into... (mips_target::low_delete_thread): ...this. (mips_linux_new_fork): Turn into... (mips_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:28 +02:00
add_linux_process (pid, 0);
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
ptid = ptid_t (pid, pid, 0);
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
new_lwp = add_lwp (ptid);
new_lwp->must_set_ptrace_flags = 1;
Share fork_inferior et al with gdbserver This is the most important (and the biggest, sorry) patch of the series. It moves fork_inferior from gdb/fork-child.c to nat/fork-inferior.c and makes all the necessary adjustments to both GDB and gdbserver to make sure everything works OK. There is no "most important change" with this patch; all changes are made in a progressive way, making sure that gdbserver had the necessary features while not breaking GDB at the same time. I decided to go ahead and implement a partial support for starting the inferior with a shell on gdbserver, although the full feature comes in the next patch. The user won't have the option to disable the startup-with-shell, and also won't be able to change which shell gdbserver will use (other than setting the $SHELL environment variable, that is). Everything is working as expected, and no regressions were present during the tests. gdb/ChangeLog: 2017-06-07 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> * Makefile.in (HFILES_NO_SRCDIR): Add "common/common-inferior.h" and "nat/fork-inferior.h". * common/common-inferior.h: New file, with contents from "gdb/inferior.h". * commom/common-utils.c: Include "common-utils.h". (stringify_argv): New function. * common/common-utils.h (stringify_argv): New prototype. * configure.nat: Add "fork-inferior.o" as a dependency for "*linux*", "fbsd*" and "nbsd*" hosts. * corefile.c (get_exec_file): Update comment. * darwin-nat.c (darwin_ptrace_him): Call "gdb_startup_inferior" instead of "startup_inferior". (darwin_create_inferior): Call "add_thread_silent" after "fork_inferior". * fork-child.c: Cleanup unnecessary includes. (SHELL_FILE): Move to "common/common-fork-child.c". (environ): Likewise. (exec_wrapper): Initialize. (get_exec_wrapper): New function. (breakup_args): Move to "common/common-fork-child.c"; rename to "breakup_args_for_exec". (escape_bang_in_quoted_argument): Move to "common/common-fork-child.c". (saved_ui): New variable. (prefork_hook): New function. (postfork_hook): Likewise. (postfork_child_hook): Likewise. (gdb_startup_inferior): Likewise. (fork_inferior): Move to "common/common-fork-child.c". Update function to support gdbserver. (startup_inferior): Likewise. * gdbcore.h (get_exec_file): Remove declaration. * gnu-nat.c (gnu_create_inferior): Call "gdb_startup_inferior" instead of "startup_inferior". Call "add_thread_silent" after "fork_inferior". * inf-ptrace.c: Include "nat/fork-inferior.h" and "utils.h". (inf_ptrace_create_inferior): Call "gdb_startup_inferior" instead of "startup_inferior". Call "add_thread_silent" after "fork_inferior". * inferior.h: Include "common-inferior.h". (trace_start_error): Move to "common/common-utils.h". (trace_start_error_with_name): Likewise. (fork_inferior): Move prototype to "nat/fork-inferior.h". (startup_inferior): Likewise. (gdb_startup_inferior): New prototype. * nat/fork-inferior.c: New file, with contents from "fork-child.c". * nat/fork-inferior.h: New file. * procfs.c (procfs_init_inferior): Call "gdb_startup_inferior" instead of "startup_inferior". Call "add_thread_silent" after "fork_inferior". * target.h (target_terminal_init): Move prototype to "target/target.h". (target_terminal_inferior): Likewise. (target_terminal_ours): Likewise. * target/target.h (target_terminal_init): New prototype, moved from "target.h". (target_terminal_inferior): Likewise. (target_terminal_ours): Likewise. * utils.c (gdb_flush_out_err): New function. gdb/gdbserver/ChangeLog: 2017-06-07 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> * Makefile.in (SFILES): Add "nat/fork-inferior.o". * configure: Regenerate. * configure.srv (srv_linux_obj): Add "fork-child.o" and "fork-inferior.o". (i[34567]86-*-lynxos*): Likewise. (spu*-*-*): Likewise. * fork-child.c: New file. * linux-low.c: Include "common-inferior.h", "nat/fork-inferior.h" and "environ.h". (linux_ptrace_fun): New function. (linux_create_inferior): Adjust function prototype to reflect change on "target.h". Adjust function code to use "fork_inferior". (linux_request_interrupt): Delete "signal_pid". * lynx-low.c: Include "common-inferior.h" and "nat/fork-inferior.h". (lynx_ptrace_fun): New function. (lynx_create_inferior): Adjust function prototype to reflect change on "target.h". Adjust function code to use "fork_inferior". * nto-low.c (nto_create_inferior): Adjust function prototype and code to reflect change on "target.h". Update comments. * server.c: Include "common-inferior.h", "nat/fork-inferior.h", "common-terminal.h" and "environ.h". (terminal_fd): Moved to fork-child.c. (old_foreground_pgrp): Likewise. (restore_old_foreground_pgrp): Likewise. (last_status): Make it global. (last_ptid): Likewise. (our_environ): New variable. (startup_with_shell): Likewise. (program_name): Likewise. (program_argv): Rename to... (program_args): ...this. (wrapper_argv): New variable. (start_inferior): Delete function. (get_exec_wrapper): New function. (get_exec_file): Likewise. (get_environ): Likewise. (prefork_hook): Likewise. (post_fork_inferior): Likewise. (postfork_hook): Likewise. (postfork_child_hook): Likewise. (handle_v_run): Update code to deal with arguments coming from the remote host. Update calls from "start_inferior" to "create_inferior". (captured_main): Likewise. Initialize environment variable. Call "have_job_control". * server.h (post_fork_inferior): New prototype. (get_environ): Likewise. (last_status): Declare. (last_ptid): Likewise. (signal_pid): Likewise. * spu-low.c: Include "common-inferior.h" and "nat/fork-inferior.h". (spu_ptrace_fun): New function. (spu_create_inferior): Adjust function prototype to reflect change on "target.h". Adjust function code to use "fork_inferior". * target.c (target_terminal_init): New function. (target_terminal_inferior): Likewise. (target_terminal_ours): Likewise. * target.h: Include <vector>. (struct target_ops) <create_inferior>: Update prototype. (create_inferior): Update macro. * utils.c (gdb_flush_out_err): New function. * win32-low.c (win32_create_inferior): Adjust function prototype and code to reflect change on "target.h". gdb/testsuite/ChangeLog: 2017-06-07 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.server/non-existing-program.exp: Update regex in order to reflect the fact that gdbserver is now using fork_inferior (with a shell) to startup the inferior.
2016-12-23 03:11:11 +01:00
post_fork_inferior (pid, program);
return pid;
}
/* Implement the post_create_inferior target_ops method. */
void
linux_process_target::post_create_inferior ()
{
struct lwp_info *lwp = get_thread_lwp (current_thread);
gdbserver/linux-low: turn 'arch_setup' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'arch_setup' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops) <arch_setup>: Delete. (class linux_process_target) <arch_setup_thread> <low_arch_setup>: New declarations. * linux-low.cc (linux_arch_setup): Delete. (linux_arch_setup_thread): Turn into... (linux_process_target::arch_setup_thread): ... this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::post_create_inferior) (linux_process_target::filter_event) * linux-x86-low.cc (class x86_target) <low_arch_setup>: New declaration. (x86_linux_update_xmltarget): Turn into... (x86_target::update_xmltarget): ...this. (x86_linux_process_qsupported): Update the call to x86_linux_update_xmltarget. (x86_arch_setup): Turn into ... (x86_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <low_arch_setup>: New declaration. (aarch64_arch_setup): Turn into ... (aarch64_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (class arm_target) <low_arch_setup>: New declaration. (arm_arch_setup): Turn into ... (arm_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-bfin-low.cc (class bfin_target) <low_arch_setup>: New declaration. (bfin_arch_setup): Turn into ... (bfin_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-cris-low.cc (class cris_target) <low_arch_setup>: New declaration. (cris_arch_setup): Turn into ... (cris_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-crisv32-low.cc (class crisv32_target) <low_arch_setup>: New declaration. (crisv32_arch_setup): Turn into ... (crisv32_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-ia64-low.cc (class ia64_target) <low_arch_setup>: New declaration. (ia64_arch_setup): Turn into ... (ia64_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-m32r-low.cc (class m32r_target) <low_arch_setup>: New declaration. (m32r_arch_setup): Turn into ... (m32r_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-m68k-low.cc (class m68k_target) <low_arch_setup>: New declaration. (m68k_arch_setup): Turn into ... (m68k_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-mips-low.cc (class mips_target) <low_arch_setup>: New declaration. (mips_arch_setup): Turn into ... (mips_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-nios2-low.cc (class nios2_target) <low_arch_setup>: New declaration. (nios2_arch_setup): Turn into ... (nios2_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (class ppc_target) <low_arch_setup>: New declaration. (ppc_arch_setup): Turn into ... (ppc_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-riscv-low.cc (class riscv_target) <low_arch_setup>: New declaration. (riscv_arch_setup): Turn into ... (riscv_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-s390-low.cc (class s390_target) <low_arch_setup>: New declaration. (s390_arch_setup): Turn into ... (s390_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-sh-low.cc (class sh_target) <low_arch_setup>: New declaration. (sh_arch_setup): Turn into ... (sh_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-sparc-low.cc (class sparc_target) <low_arch_setup>: New declaration. (sparc_arch_setup): Turn into ... (sparc_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-tic6x-low.cc (class tic6x_target) <low_arch_setup>: New declaration. (tic6x_arch_setup): Turn into ... (tic6x_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-tile-low.cc (class tile_target) <low_arch_setup>: New declaration. (tile_arch_setup): Turn into ... (tile_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-xtensa-low.cc (class xtensa_target) <low_arch_setup>: New declaration. (xtensa_arch_setup): Turn into ... (xtensa_target::low_arch_setup): ...this. (the_low_target): Remove the op field.
2020-04-02 15:11:23 +02:00
low_arch_setup ();
if (lwp->must_set_ptrace_flags)
{
struct process_info *proc = current_process ();
int options = linux_low_ptrace_options (proc->attached);
linux_enable_event_reporting (lwpid_of (current_thread), options);
lwp->must_set_ptrace_flags = 0;
}
}
PR server/16255: gdbserver cannot attach to a second inferior that is multi-threaded. On Linux, we need to explicitly ptrace attach to all lwps of a process. Because GDB might not be connected yet when an attach is requested, and thus it may not be possible to activate thread_db, as that requires access to symbols (IOW, gdbserver --attach), a while ago we make linux_attach loop over the lwps as listed by /proc/PID/task to find the lwps to attach to. linux_attach_lwp_1 has: ... if (initial) /* If lwp is the tgid, we handle adding existing threads later. Otherwise we just add lwp without bothering about any other threads. */ ptid = ptid_build (lwpid, lwpid, 0); else { /* Note that extracting the pid from the current inferior is safe, since we're always called in the context of the same process as this new thread. */ int pid = pid_of (current_inferior); ptid = ptid_build (pid, lwpid, 0); } That "safe" comment referred to linux_attach_lwp being called by thread-db.c. But this was clearly missed when a new call to linux_attach_lwp_1 was added to linux_attach. As a result, current_inferior will be set to some random process, and non-initial lwps of the second inferior get assigned the pid of the wrong inferior. E.g., in the case of attaching to two inferiors, for the second inferior (and so on), non-initial lwps of the second inferior get assigned the pid of the first inferior. This doesn't trigger on the first inferior, when current_inferior is NULL, add_thread switches the current inferior to the newly added thread. Rather than making linux_attach switch current_inferior temporarily (thus avoiding further reliance on global state), or making linux_attach_lwp_1 get the tgid from /proc, which add extra syscalls, and will be wrong in case of the user having originally attached directly to a non-tgid lwp, and then that lwp spawning new clones (the ptid.pid field of further new clones should be the same as the original lwp's pid, which is not the tgid), we note that callers of linux_attach_lwp/linux_attach_lwp_1 always have the right pid handy already, so they can pass it down along with the lwpid. The only other reason for the "initial" parameter is to error out instead of warn in case of attach failure, when we're first attaching to a process. There are only three callers of linux_attach_lwp/linux_attach_lwp_1, and each wants to print a different warn/error string, so we can just move the error/warn out of linux_attach_lwp_1 to the callers, thus getting rid of the "initial" parameter. There really nothing gdbserver-specific about attaching to two threaded processes, so this adds a new test under gdb.multi/. The test passes cleanly against the native GNU/Linux target, but fails/triggers the bug against GDBserver (before the patch), with the native-extended-remote board (as plain remote doesn't support multi-process). Tested on x86_64 Fedora 17, with the native-extended-gdbserver board. gdb/gdbserver/ 2014-04-25 Pedro Alves <palves@redhat.com> PR server/16255 * linux-low.c (linux_attach_fail_reason_string): New function. (linux_attach_lwp): Delete. (linux_attach_lwp_1): Rename to ... (linux_attach_lwp): ... this. Take a ptid instead of a pid as argument. Remove "initial" parameter. Return int instead of void. Don't error or warn here. (linux_attach): Adjust to call linux_attach_lwp. Call error on failure to attach to the tgid. Call warning when failing to attach to an lwp. * linux-low.h (linux_attach_lwp): Take a ptid instead of a pid as argument. Remove "initial" parameter. Return int instead of void. Don't error or warn here. (linux_attach_fail_reason_string): New declaration. * thread-db.c (attach_thread): Adjust to linux_attach_lwp's interface change. Use linux_attach_fail_reason_string. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> PR server/16255 * common/linux-ptrace.c (linux_ptrace_attach_warnings): Rename to ... (linux_ptrace_attach_fail_reason): ... this. Remove "warning: " and newline from built string. * common/linux-ptrace.h (linux_ptrace_attach_warnings): Rename to ... (linux_ptrace_attach_fail_reason): ... this. * linux-nat.c (linux_nat_attach): Adjust to use linux_ptrace_attach_fail_reason. gdb/testsuite/ 2014-04-25 Simon Marchi <simon.marchi@ericsson.com> Pedro Alves <palves@redhat.com> PR server/16255 * gdb.multi/multi-attach.c: New file. * gdb.multi/multi-attach.exp: New file.
2014-04-25 20:07:33 +02:00
int
gdbserver/linux-low: turn process/thread addition/deletion ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'new_process', 'delete_process', 'new_thread', 'delete_thread', and 'new_fork' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <add_linux_process> <add_lwp> <delete_lwp> <attach_lwp> <detach_one_lwp> <check_zombie_leaders> <filter_exit_event> <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. * linux-low.cc (delete_lwp): Turn into... (linux_process_target::delete_lwp): ...this. (linux_process_target::low_delete_thread): Define. (linux_add_process): Turn into... (linux_process_target::add_linux_process): ...this. (linux_process_target::low_new_process): Define. (linux_process_target::low_delete_process): Define. (linux_process_target::low_new_fork): Define. (add_lwp): Turn into... (linux_process_target::add_lwp): ...this. (linux_process_target::low_new_thread): Define. (linux_attach_lwp): Turn into... (linux_process_target::attach_lwp): ...this. (linux_detach_one_lwp): Turn into... (linux_process_target::detach_one_lwp): ...this. (linux_detach_lwp_callback): Remove and inline... (linux_process_target::detach): ...here. (check_zombie_leaders): Turn into... (linux_process_target::check_zombie_leaders): ...this. (filter_exit_event): Turn into... (linux_process_target::filter_exit_event): ...this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::create_inferior) (attach_proc_task_lwp_callback) (linux_process_target::attach) (linux_process_target::detach) (linux_process_target::mourn) * thread-db.cc (attach_thread) * linux-x86-low.cc (class x86_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (x86_linux_new_process): Turn into... (x86_target::low_new_process): ...this. (x86_linux_delete_process): Turn into... (x86_target::low_delete_process): ...this. (x86_target::low_new_thread): Define. (x86_target::low_delete_thread): Define. (x86_linux_new_fork): Turn into... (x86_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (aarch64_linux_new_process): Turn into... (aarch64_target::low_new_process): ...this. (aarch64_linux_delete_process): Turn into... (aarch64_target::low_delete_process): ...this. (aarch64_target::low_new_thread): Define. (aarch64_target::low_delete_thread): Define. (aarch64_linux_new_fork): Turn into... (aarch64_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (arm_new_process): Turn into... (arm_target::low_new_process): ...this. (arm_delete_process): Turn into... (arm_target::low_delete_process): ...this. (arm_new_thread): Turn into... (arm_target::low_new_thread): ...this. (arm_delete_thread): Turn into... (arm_target::low_delete_thread): ...this. (arm_new_fork): Turn into... (arm_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (mips_linux_new_process): Turn into... (mips_target::low_new_process): ...this. (mips_linux_delete_process): Turn into... (mips_target::low_delete_process): ...this. (mips_linux_new_thread): Turn into... (mips_target::low_new_thread): ...this. (mips_linux_delete_thread): Turn into... (mips_target::low_delete_thread): ...this. (mips_linux_new_fork): Turn into... (mips_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:28 +02:00
linux_process_target::attach_lwp (ptid_t ptid)
{
Rename "process" to "lwp" throughout. * linux-low.c (all_processes): Rename to... (all_lwps): ... this. (inferior_pid, handle_extended_wait, get_stop_pc): Adjust. (add_process): Rename to ... (add_lwp): ... this. Adjust. (linux_create_inferior): Adjust. (linux_attach_lwp): Adjust. (linux_attach): Adjust. (linux_kill_one_process): Rename to ... (linux_kill_one_lwp): ... this. Adjust. (linux_kill): Adjust. (linux_detach_one_process): Rename to ... (linux_detach_one_lwp): ... this. Adjust. (linux_detach): Adjust. (check_removed_breakpoint): Adjust. (status_pending_p): Adjust. (linux_wait_for_process): Rename to ... (linux_wait_for_lwp): ... this. Adjust. (linux_wait_for_event): Adjust. (send_sigstop): Adjust. (wait_for_sigstop): Adjust. (stop_all_processes): Rename to ... (stop_all_lwps): ... this. (linux_resume_one_process): Rename to ... (linux_resume_one_lwp): ... this. Adjust. (linux_set_resume_request, linux_continue_one_thread) (linux_queue_one_thread, resume_status_pending_p) (usr_store_inferior_registers, regsets_store_inferior_registers) (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Adjust. * linux-low.h (get_process): Rename to ... (get_lwp): ... this. Adjust. (get_thread_process): Rename to ... (get_thread_lwp): ... this. Adjust. (get_process_thread): Rename to ... (get_lwp_thread): ... this. Adjust. (struct process_info): Rename to ... (struct lwp_info): ... this. (all_processes): Rename to ... (all_lwps): ... this. * proc-service.c (ps_lgetregs): Adjust. * thread-db.c (thread_db_create_event, find_one_thread) (maybe_attach_thread, thread_db_get_tls_address): Adjust.
2009-03-17 21:25:35 +01:00
struct lwp_info *new_lwp;
Remove ptid_get_lwp This removes ptid_get_lwp in favor of calling the ptid_t::lwp method. gdb/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * common/ptid.c (ptid_get_lwp): Remove. * common/ptid.h (ptid_get_lwp): Don't declare. * aarch64-linux-nat.c: Update. * ada-tasks.c: Update. * aix-thread.c: Update. * amd64-linux-nat.c: Update. * arm-linux-nat.c: Update. * corelow.c: Update. * fbsd-nat.c: Update. * fbsd-tdep.c: Update. * gnu-nat.c: Update. * i386-cygwin-tdep.c: Update. * i386-gnu-nat.c: Update. * i386-linux-nat.c: Update. * ia64-linux-nat.c: Update. * inf-ptrace.c: Update. * infrun.c: Update. * linux-fork.c: Update. * linux-nat.c: Update. * linux-tdep.c: Update. * linux-thread-db.c: Update. * mips-linux-nat.c: Update. * nat/aarch64-linux-hw-point.c: Update. * nat/aarch64-linux.c: Update. * nat/linux-btrace.c: Update. * nat/linux-osdata.c: Update. * nat/linux-procfs.c: Update. * nat/x86-linux-dregs.c: Update. * obsd-nat.c: Update. * ppc-fbsd-nat.c: Update. * ppc-linux-nat.c: Update. * procfs.c: Update. * python/py-infthread.c: Update. * ravenscar-thread.c: Update. * remote.c: Update. * s390-linux-nat.c: Update. * sol-thread.c: Update. * sol2-tdep.c: Update. * spu-linux-nat.c: Update. * x86-linux-nat.c: Update. * xtensa-linux-nat.c: Update. gdb/gdbserver/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * linux-low.c: Update. * linux-mips-low.c: Update. * lynx-low.c: Update. * nto-low.c: Update. * remote-utils.c: Update. * server.c: Update. * spu-low.c: Update. * target.c: Update. * thread-db.c: Update.
2018-06-11 20:10:09 +02:00
int lwpid = ptid.lwp ();
if (ptrace (PTRACE_ATTACH, lwpid, (PTRACE_TYPE_ARG3) 0, (PTRACE_TYPE_ARG4) 0)
!= 0)
PR server/16255: gdbserver cannot attach to a second inferior that is multi-threaded. On Linux, we need to explicitly ptrace attach to all lwps of a process. Because GDB might not be connected yet when an attach is requested, and thus it may not be possible to activate thread_db, as that requires access to symbols (IOW, gdbserver --attach), a while ago we make linux_attach loop over the lwps as listed by /proc/PID/task to find the lwps to attach to. linux_attach_lwp_1 has: ... if (initial) /* If lwp is the tgid, we handle adding existing threads later. Otherwise we just add lwp without bothering about any other threads. */ ptid = ptid_build (lwpid, lwpid, 0); else { /* Note that extracting the pid from the current inferior is safe, since we're always called in the context of the same process as this new thread. */ int pid = pid_of (current_inferior); ptid = ptid_build (pid, lwpid, 0); } That "safe" comment referred to linux_attach_lwp being called by thread-db.c. But this was clearly missed when a new call to linux_attach_lwp_1 was added to linux_attach. As a result, current_inferior will be set to some random process, and non-initial lwps of the second inferior get assigned the pid of the wrong inferior. E.g., in the case of attaching to two inferiors, for the second inferior (and so on), non-initial lwps of the second inferior get assigned the pid of the first inferior. This doesn't trigger on the first inferior, when current_inferior is NULL, add_thread switches the current inferior to the newly added thread. Rather than making linux_attach switch current_inferior temporarily (thus avoiding further reliance on global state), or making linux_attach_lwp_1 get the tgid from /proc, which add extra syscalls, and will be wrong in case of the user having originally attached directly to a non-tgid lwp, and then that lwp spawning new clones (the ptid.pid field of further new clones should be the same as the original lwp's pid, which is not the tgid), we note that callers of linux_attach_lwp/linux_attach_lwp_1 always have the right pid handy already, so they can pass it down along with the lwpid. The only other reason for the "initial" parameter is to error out instead of warn in case of attach failure, when we're first attaching to a process. There are only three callers of linux_attach_lwp/linux_attach_lwp_1, and each wants to print a different warn/error string, so we can just move the error/warn out of linux_attach_lwp_1 to the callers, thus getting rid of the "initial" parameter. There really nothing gdbserver-specific about attaching to two threaded processes, so this adds a new test under gdb.multi/. The test passes cleanly against the native GNU/Linux target, but fails/triggers the bug against GDBserver (before the patch), with the native-extended-remote board (as plain remote doesn't support multi-process). Tested on x86_64 Fedora 17, with the native-extended-gdbserver board. gdb/gdbserver/ 2014-04-25 Pedro Alves <palves@redhat.com> PR server/16255 * linux-low.c (linux_attach_fail_reason_string): New function. (linux_attach_lwp): Delete. (linux_attach_lwp_1): Rename to ... (linux_attach_lwp): ... this. Take a ptid instead of a pid as argument. Remove "initial" parameter. Return int instead of void. Don't error or warn here. (linux_attach): Adjust to call linux_attach_lwp. Call error on failure to attach to the tgid. Call warning when failing to attach to an lwp. * linux-low.h (linux_attach_lwp): Take a ptid instead of a pid as argument. Remove "initial" parameter. Return int instead of void. Don't error or warn here. (linux_attach_fail_reason_string): New declaration. * thread-db.c (attach_thread): Adjust to linux_attach_lwp's interface change. Use linux_attach_fail_reason_string. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> PR server/16255 * common/linux-ptrace.c (linux_ptrace_attach_warnings): Rename to ... (linux_ptrace_attach_fail_reason): ... this. Remove "warning: " and newline from built string. * common/linux-ptrace.h (linux_ptrace_attach_warnings): Rename to ... (linux_ptrace_attach_fail_reason): ... this. * linux-nat.c (linux_nat_attach): Adjust to use linux_ptrace_attach_fail_reason. gdb/testsuite/ 2014-04-25 Simon Marchi <simon.marchi@ericsson.com> Pedro Alves <palves@redhat.com> PR server/16255 * gdb.multi/multi-attach.c: New file. * gdb.multi/multi-attach.exp: New file.
2014-04-25 20:07:33 +02:00
return errno;
* inferiors.c (change_inferior_id): Delete. (add_pid_to_list, pull_pid_from_list): New. * linux-low.c (PTRACE_SETOPTIONS, PTRACE_GETEVENTMSG) (PTRACE_O_TRACESYSGOOD, PTRACE_O_TRACEFORK, PTRACE_O_TRACEVFORK) (PTRACE_O_TRACECLONE, PTRACE_O_TRACEEXEC, PTRACE_O_TRACEVFORKDONE) (PTRACE_O_TRACEEXIT, PTRACE_EVENT_FORK, PTRACE_EVENT_VFORK) (PTRACE_EVENT_CLONE, PTRACE_EVENT_EXEC, PTRACE_EVENT_VFORK_DONE) (PTRACE_EVENT_EXIT, __WALL): Provide default definitions. (stopped_pids, thread_db_active, must_set_ptrace_flags): New variables. (using_threads): Always set to 1. (handle_extended_wait): New. (add_process): Do not set TID. (linux_create_inferior): Set must_set_ptrace_flags. (linux_attach_lwp): Remove TID argument. Do not check using_threads. Use PTRACE_SETOPTIONS. Call new_thread_notify. Update all callers. (linux_thread_alive): Rename TID argument to LWPID. (linux_wait_for_process): Handle unknown processes. Do not use TID. (linux_wait_for_event): Do not use TID or check using_threads. Update call to dead_thread_notify. Call handle_extended_wait. (linux_create_inferior): Use PTRACE_SETOPTIONS. (send_sigstop): Delete sigstop_sent. (wait_for_sigstop): Avoid TID. (linux_supports_tracefork_flag, linux_tracefork_child, my_waitpid) (linux_test_for_tracefork): New. (linux_lookup_signals): Use thread_db_active and linux_supports_tracefork_flag. (initialize_low): Use thread_db_active and linux_test_for_tracefork. * linux-low.h (get_process_thread): Avoid TID. (struct process_ifo): Move thread_known and tid to the end. Remove sigstop_sent. (linux_attach_lwp, thread_db_init): Update prototypes. * server.h (change_inferior_id): Delete prototype. (add_pid_to_list, pull_pid_from_list): New prototypes. * thread-db.c (thread_db_use_events): New. (find_first_thread): Rename to... (find_one_thread): ...this. Update callers and messages. Do not call fatal. Check thread_db_use_events. Do not call change_inferior_id or new_thread_notify. (maybe_attach_thread): Update. Do not call new_thread_notify. (thread_db_init): Set thread_db_use_events. Check use_events. * utils.c (fatal, warning): Correct message prefix.
2007-10-23 22:05:03 +02:00
new_lwp = add_lwp (ptid);
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
/* We need to wait for SIGSTOP before being able to make the next
ptrace call on this LWP. */
new_lwp->must_set_ptrace_flags = 1;
if (linux_proc_pid_is_stopped (lwpid))
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Attached to a stopped process\n");
/* The process is definitely stopped. It is in a job control
stop, unless the kernel predates the TASK_STOPPED /
TASK_TRACED distinction, in which case it might be in a
ptrace stop. Make sure it is in a ptrace stop; from there we
can kill it, signal it, et cetera.
First make sure there is a pending SIGSTOP. Since we are
already attached, the process can not transition from stopped
to running without a PTRACE_CONT; so we know this signal will
go into the queue. The SIGSTOP generated by PTRACE_ATTACH is
probably already in the queue (unless this kernel is old
enough to use TASK_STOPPED for ptrace stops); but since
SIGSTOP is not an RT signal, it can only be queued once. */
kill_lwp (lwpid, SIGSTOP);
/* Finally, resume the stopped process. This will deliver the
SIGSTOP (or a higher priority signal, just like normal
PTRACE_ATTACH), which we'll catch later on. */
ptrace (PTRACE_CONT, lwpid, (PTRACE_TYPE_ARG3) 0, (PTRACE_TYPE_ARG4) 0);
}
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
/* The next time we wait for this LWP we'll see a SIGSTOP as PTRACE_ATTACH
brings it to a halt.
There are several cases to consider here:
1) gdbserver has already attached to the process and is being notified
of a new thread that is being created.
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
In this case we should ignore that SIGSTOP and resume the
process. This is handled below by setting stop_expected = 1,
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
and the fact that add_thread sets last_resume_kind ==
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
resume_continue.
2) This is the first thread (the process thread), and we're attaching
to it via attach_inferior.
In this case we want the process thread to stop.
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
This is handled by having linux_attach set last_resume_kind ==
resume_stop after we return.
If the pid we are attaching to is also the tgid, we attach to and
stop all the existing threads. Otherwise, we attach to pid and
ignore any other threads in the same group as this pid.
3) GDB is connecting to gdbserver and is requesting an enumeration of all
existing threads.
In this case we want the thread to stop.
FIXME: This case is currently not properly handled.
We should wait for the SIGSTOP but don't. Things work apparently
because enough time passes between when we ptrace (ATTACH) and when
gdb makes the next ptrace call on the thread.
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
On the other hand, if we are currently trying to stop all threads, we
should treat the new thread as if we had sent it a SIGSTOP. This works
Rename "process" to "lwp" throughout. * linux-low.c (all_processes): Rename to... (all_lwps): ... this. (inferior_pid, handle_extended_wait, get_stop_pc): Adjust. (add_process): Rename to ... (add_lwp): ... this. Adjust. (linux_create_inferior): Adjust. (linux_attach_lwp): Adjust. (linux_attach): Adjust. (linux_kill_one_process): Rename to ... (linux_kill_one_lwp): ... this. Adjust. (linux_kill): Adjust. (linux_detach_one_process): Rename to ... (linux_detach_one_lwp): ... this. Adjust. (linux_detach): Adjust. (check_removed_breakpoint): Adjust. (status_pending_p): Adjust. (linux_wait_for_process): Rename to ... (linux_wait_for_lwp): ... this. Adjust. (linux_wait_for_event): Adjust. (send_sigstop): Adjust. (wait_for_sigstop): Adjust. (stop_all_processes): Rename to ... (stop_all_lwps): ... this. (linux_resume_one_process): Rename to ... (linux_resume_one_lwp): ... this. Adjust. (linux_set_resume_request, linux_continue_one_thread) (linux_queue_one_thread, resume_status_pending_p) (usr_store_inferior_registers, regsets_store_inferior_registers) (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Adjust. * linux-low.h (get_process): Rename to ... (get_lwp): ... this. Adjust. (get_thread_process): Rename to ... (get_thread_lwp): ... this. Adjust. (get_process_thread): Rename to ... (get_lwp_thread): ... this. Adjust. (struct process_info): Rename to ... (struct lwp_info): ... this. (all_processes): Rename to ... (all_lwps): ... this. * proc-service.c (ps_lgetregs): Adjust. * thread-db.c (thread_db_create_event, find_one_thread) (maybe_attach_thread, thread_db_get_tls_address): Adjust.
2009-03-17 21:25:35 +01:00
because we are guaranteed that the add_lwp call above added us to the
end of the list, and so the new thread has not yet reached
wait_for_sigstop (but will). */
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
new_lwp->stop_expected = 1;
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
PR server/16255: gdbserver cannot attach to a second inferior that is multi-threaded. On Linux, we need to explicitly ptrace attach to all lwps of a process. Because GDB might not be connected yet when an attach is requested, and thus it may not be possible to activate thread_db, as that requires access to symbols (IOW, gdbserver --attach), a while ago we make linux_attach loop over the lwps as listed by /proc/PID/task to find the lwps to attach to. linux_attach_lwp_1 has: ... if (initial) /* If lwp is the tgid, we handle adding existing threads later. Otherwise we just add lwp without bothering about any other threads. */ ptid = ptid_build (lwpid, lwpid, 0); else { /* Note that extracting the pid from the current inferior is safe, since we're always called in the context of the same process as this new thread. */ int pid = pid_of (current_inferior); ptid = ptid_build (pid, lwpid, 0); } That "safe" comment referred to linux_attach_lwp being called by thread-db.c. But this was clearly missed when a new call to linux_attach_lwp_1 was added to linux_attach. As a result, current_inferior will be set to some random process, and non-initial lwps of the second inferior get assigned the pid of the wrong inferior. E.g., in the case of attaching to two inferiors, for the second inferior (and so on), non-initial lwps of the second inferior get assigned the pid of the first inferior. This doesn't trigger on the first inferior, when current_inferior is NULL, add_thread switches the current inferior to the newly added thread. Rather than making linux_attach switch current_inferior temporarily (thus avoiding further reliance on global state), or making linux_attach_lwp_1 get the tgid from /proc, which add extra syscalls, and will be wrong in case of the user having originally attached directly to a non-tgid lwp, and then that lwp spawning new clones (the ptid.pid field of further new clones should be the same as the original lwp's pid, which is not the tgid), we note that callers of linux_attach_lwp/linux_attach_lwp_1 always have the right pid handy already, so they can pass it down along with the lwpid. The only other reason for the "initial" parameter is to error out instead of warn in case of attach failure, when we're first attaching to a process. There are only three callers of linux_attach_lwp/linux_attach_lwp_1, and each wants to print a different warn/error string, so we can just move the error/warn out of linux_attach_lwp_1 to the callers, thus getting rid of the "initial" parameter. There really nothing gdbserver-specific about attaching to two threaded processes, so this adds a new test under gdb.multi/. The test passes cleanly against the native GNU/Linux target, but fails/triggers the bug against GDBserver (before the patch), with the native-extended-remote board (as plain remote doesn't support multi-process). Tested on x86_64 Fedora 17, with the native-extended-gdbserver board. gdb/gdbserver/ 2014-04-25 Pedro Alves <palves@redhat.com> PR server/16255 * linux-low.c (linux_attach_fail_reason_string): New function. (linux_attach_lwp): Delete. (linux_attach_lwp_1): Rename to ... (linux_attach_lwp): ... this. Take a ptid instead of a pid as argument. Remove "initial" parameter. Return int instead of void. Don't error or warn here. (linux_attach): Adjust to call linux_attach_lwp. Call error on failure to attach to the tgid. Call warning when failing to attach to an lwp. * linux-low.h (linux_attach_lwp): Take a ptid instead of a pid as argument. Remove "initial" parameter. Return int instead of void. Don't error or warn here. (linux_attach_fail_reason_string): New declaration. * thread-db.c (attach_thread): Adjust to linux_attach_lwp's interface change. Use linux_attach_fail_reason_string. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> PR server/16255 * common/linux-ptrace.c (linux_ptrace_attach_warnings): Rename to ... (linux_ptrace_attach_fail_reason): ... this. Remove "warning: " and newline from built string. * common/linux-ptrace.h (linux_ptrace_attach_warnings): Rename to ... (linux_ptrace_attach_fail_reason): ... this. * linux-nat.c (linux_nat_attach): Adjust to use linux_ptrace_attach_fail_reason. gdb/testsuite/ 2014-04-25 Simon Marchi <simon.marchi@ericsson.com> Pedro Alves <palves@redhat.com> PR server/16255 * gdb.multi/multi-attach.c: New file. * gdb.multi/multi-attach.exp: New file.
2014-04-25 20:07:33 +02:00
return 0;
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
}
Linux: on attach, attach to lwps listed under /proc/$pid/task/ ... instead of relying on libthread_db. I wrote a test that attaches to a program that constantly spawns short-lived threads, which exposed several issues. This is one of them. On Linux, we need to attach to all threads of a process (thread group) individually. We currently rely on libthread_db to list the threads, but that is problematic, because libthread_db relies on reading data structures out of the inferior (which may well be corrupted). If threads are being created or exiting just while we try to attach, we may trip on inconsistencies in the inferior's thread list. To work around that, when we see a seemingly corrupt list, we currently retry a few times: static void thread_db_find_new_threads_2 (ptid_t ptid, int until_no_new) { ... if (until_no_new) { /* Require 4 successive iterations which do not find any new threads. The 4 is a heuristic: there is an inherent race here, and I have seen that 2 iterations in a row are not always sufficient to "capture" all threads. */ ... That heuristic may well fail, and when it does, we end up with threads in the program that aren't under GDB's control. That's obviously bad and results in quite mistifying failures, like e.g., the process dying for seeminly no reason when a thread that wasn't attached trips on a breakpoint. There's really no reason to rely on libthread_db for this nowadays when we have /proc mounted. In that case, which is the usual case, we can list the LWPs from /proc/PID/task/. In fact, GDBserver is already doing this. The patch factors out that code that knows to walk the task/ directory out of GDBserver, and makes GDB use it too. Like GDBserver, the patch makes GDB attach to LWPs and _not_ wait for them to stop immediately. Instead, we just tag the LWP as having an expected stop. Because we can only set the ptrace options when the thread stops, we need a new flag in the lwp structure to keep track of whether we've already set the ptrace options, just like in GDBserver. Note that nothing issues any ptrace command to the threads between the PTRACE_ATTACH and the stop, so this is safe (unlike one scenario described in gdbserver's linux-low.c). When we attach to a program that has threads exiting while we attach, it's easy to race with a thread just exiting as we try to attach to it, like: #1 - get current list of threads #2 - attach to each listed thread #3 - ooops, attach failed, thread is already gone As this is pretty normal, we shouldn't be issuing a scary warning in step #3. When #3 happens, PTRACE_ATTACH usually fails with ESRCH, but sometimes we'll see EPERM as well. That happens when the kernel still has the thread in its task list, but the thread is marked as dead. Unfortunately, EPERM is ambiguous and we'll get it also on other scenarios where the thread isn't dead, and in those cases, it's useful to get a warning. To distiguish the cases, when we get an EPERM failure, we open /proc/PID/status, and check the thread's state -- if the /proc file no longer exists, or the state is "Z (Zombie)" or "X (Dead)", we ignore the EPERM error silently; otherwise, we'll warn. Unfortunately, there seems to be a kernel race here. Sometimes I get EPERM, and then the /proc state still indicates "R (Running)"... If we wait a bit and retry, we do end up seeing X or Z state, or get an ESRCH. I thought of making GDB retry the attach a few times, but even with a 500ms wait and 4 retries, I still see the warning sometimes. I haven't been able to identify the kernel path that causes this yet, but in any case, it looks like a kernel bug to me. As this just results failure to suppress a warning that we've been printing since about forever anyway, I'm just making the test cope with it, and issue an XFAIL. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (linux_attach_fail_reason_string): Move to nat/linux-ptrace.c, and rename. (linux_attach_lwp): Update comment. (attach_proc_task_lwp_callback): New function. (linux_attach): Adjust to rename and use linux_proc_attach_tgid_threads. (linux_attach_fail_reason_string): Delete declaration. gdb/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-nat.c (attach_proc_task_lwp_callback): New function. (linux_nat_attach): Use linux_proc_attach_tgid_threads. (wait_lwp, linux_nat_filter_event): If not set yet, set the lwp's ptrace option flags. * linux-nat.h (struct lwp_info) <must_set_ptrace_flags>: New field. * nat/linux-procfs.c: Include <dirent.h>. (linux_proc_get_int): New parameter "warn". Handle it. (linux_proc_get_tgid): Adjust. (linux_proc_get_tracerpid): Rename to ... (linux_proc_get_tracerpid_nowarn): ... this. (linux_proc_pid_get_state): New function, factored out from (linux_proc_pid_has_state): ... this. Add new parameter "warn" and handle it. (linux_proc_pid_is_gone): New function. (linux_proc_pid_is_stopped): Adjust. (linux_proc_pid_is_zombie_maybe_warn) (linux_proc_pid_is_zombie_nowarn): New functions. (linux_proc_pid_is_zombie): Use linux_proc_pid_is_zombie_maybe_warn. (linux_proc_attach_tgid_threads): New function. * nat/linux-procfs.h (linux_proc_get_tgid): Update comment. (linux_proc_get_tracerpid): Rename to ... (linux_proc_get_tracerpid_nowarn): ... this, and update comment. (linux_proc_pid_is_gone): New declaration. (linux_proc_pid_is_zombie): Update comment. (linux_proc_pid_is_zombie_nowarn): New declaration. (linux_proc_attach_lwp_func): New typedef. (linux_proc_attach_tgid_threads): New declaration. * nat/linux-ptrace.c (linux_ptrace_attach_fail_reason): Adjust to use nowarn functions. (linux_ptrace_attach_fail_reason_string): Move here from gdbserver/linux-low.c and rename. (ptrace_supports_feature): If the current ptrace options are not known yet, check them now, instead of asserting. * nat/linux-ptrace.h (linux_ptrace_attach_fail_reason_string): Declare.
2014-12-16 17:12:24 +01:00
/* Callback for linux_proc_attach_tgid_threads. Attach to PTID if not
already attached. Returns true if a new LWP is found, false
otherwise. */
static int
attach_proc_task_lwp_callback (ptid_t ptid)
{
/* Is this a new thread? */
if (find_thread_ptid (ptid) == NULL)
{
Remove ptid_get_lwp This removes ptid_get_lwp in favor of calling the ptid_t::lwp method. gdb/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * common/ptid.c (ptid_get_lwp): Remove. * common/ptid.h (ptid_get_lwp): Don't declare. * aarch64-linux-nat.c: Update. * ada-tasks.c: Update. * aix-thread.c: Update. * amd64-linux-nat.c: Update. * arm-linux-nat.c: Update. * corelow.c: Update. * fbsd-nat.c: Update. * fbsd-tdep.c: Update. * gnu-nat.c: Update. * i386-cygwin-tdep.c: Update. * i386-gnu-nat.c: Update. * i386-linux-nat.c: Update. * ia64-linux-nat.c: Update. * inf-ptrace.c: Update. * infrun.c: Update. * linux-fork.c: Update. * linux-nat.c: Update. * linux-tdep.c: Update. * linux-thread-db.c: Update. * mips-linux-nat.c: Update. * nat/aarch64-linux-hw-point.c: Update. * nat/aarch64-linux.c: Update. * nat/linux-btrace.c: Update. * nat/linux-osdata.c: Update. * nat/linux-procfs.c: Update. * nat/x86-linux-dregs.c: Update. * obsd-nat.c: Update. * ppc-fbsd-nat.c: Update. * ppc-linux-nat.c: Update. * procfs.c: Update. * python/py-infthread.c: Update. * ravenscar-thread.c: Update. * remote.c: Update. * s390-linux-nat.c: Update. * sol-thread.c: Update. * sol2-tdep.c: Update. * spu-linux-nat.c: Update. * x86-linux-nat.c: Update. * xtensa-linux-nat.c: Update. gdb/gdbserver/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * linux-low.c: Update. * linux-mips-low.c: Update. * lynx-low.c: Update. * nto-low.c: Update. * remote-utils.c: Update. * server.c: Update. * spu-low.c: Update. * target.c: Update. * thread-db.c: Update.
2018-06-11 20:10:09 +02:00
int lwpid = ptid.lwp ();
Linux: on attach, attach to lwps listed under /proc/$pid/task/ ... instead of relying on libthread_db. I wrote a test that attaches to a program that constantly spawns short-lived threads, which exposed several issues. This is one of them. On Linux, we need to attach to all threads of a process (thread group) individually. We currently rely on libthread_db to list the threads, but that is problematic, because libthread_db relies on reading data structures out of the inferior (which may well be corrupted). If threads are being created or exiting just while we try to attach, we may trip on inconsistencies in the inferior's thread list. To work around that, when we see a seemingly corrupt list, we currently retry a few times: static void thread_db_find_new_threads_2 (ptid_t ptid, int until_no_new) { ... if (until_no_new) { /* Require 4 successive iterations which do not find any new threads. The 4 is a heuristic: there is an inherent race here, and I have seen that 2 iterations in a row are not always sufficient to "capture" all threads. */ ... That heuristic may well fail, and when it does, we end up with threads in the program that aren't under GDB's control. That's obviously bad and results in quite mistifying failures, like e.g., the process dying for seeminly no reason when a thread that wasn't attached trips on a breakpoint. There's really no reason to rely on libthread_db for this nowadays when we have /proc mounted. In that case, which is the usual case, we can list the LWPs from /proc/PID/task/. In fact, GDBserver is already doing this. The patch factors out that code that knows to walk the task/ directory out of GDBserver, and makes GDB use it too. Like GDBserver, the patch makes GDB attach to LWPs and _not_ wait for them to stop immediately. Instead, we just tag the LWP as having an expected stop. Because we can only set the ptrace options when the thread stops, we need a new flag in the lwp structure to keep track of whether we've already set the ptrace options, just like in GDBserver. Note that nothing issues any ptrace command to the threads between the PTRACE_ATTACH and the stop, so this is safe (unlike one scenario described in gdbserver's linux-low.c). When we attach to a program that has threads exiting while we attach, it's easy to race with a thread just exiting as we try to attach to it, like: #1 - get current list of threads #2 - attach to each listed thread #3 - ooops, attach failed, thread is already gone As this is pretty normal, we shouldn't be issuing a scary warning in step #3. When #3 happens, PTRACE_ATTACH usually fails with ESRCH, but sometimes we'll see EPERM as well. That happens when the kernel still has the thread in its task list, but the thread is marked as dead. Unfortunately, EPERM is ambiguous and we'll get it also on other scenarios where the thread isn't dead, and in those cases, it's useful to get a warning. To distiguish the cases, when we get an EPERM failure, we open /proc/PID/status, and check the thread's state -- if the /proc file no longer exists, or the state is "Z (Zombie)" or "X (Dead)", we ignore the EPERM error silently; otherwise, we'll warn. Unfortunately, there seems to be a kernel race here. Sometimes I get EPERM, and then the /proc state still indicates "R (Running)"... If we wait a bit and retry, we do end up seeing X or Z state, or get an ESRCH. I thought of making GDB retry the attach a few times, but even with a 500ms wait and 4 retries, I still see the warning sometimes. I haven't been able to identify the kernel path that causes this yet, but in any case, it looks like a kernel bug to me. As this just results failure to suppress a warning that we've been printing since about forever anyway, I'm just making the test cope with it, and issue an XFAIL. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (linux_attach_fail_reason_string): Move to nat/linux-ptrace.c, and rename. (linux_attach_lwp): Update comment. (attach_proc_task_lwp_callback): New function. (linux_attach): Adjust to rename and use linux_proc_attach_tgid_threads. (linux_attach_fail_reason_string): Delete declaration. gdb/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-nat.c (attach_proc_task_lwp_callback): New function. (linux_nat_attach): Use linux_proc_attach_tgid_threads. (wait_lwp, linux_nat_filter_event): If not set yet, set the lwp's ptrace option flags. * linux-nat.h (struct lwp_info) <must_set_ptrace_flags>: New field. * nat/linux-procfs.c: Include <dirent.h>. (linux_proc_get_int): New parameter "warn". Handle it. (linux_proc_get_tgid): Adjust. (linux_proc_get_tracerpid): Rename to ... (linux_proc_get_tracerpid_nowarn): ... this. (linux_proc_pid_get_state): New function, factored out from (linux_proc_pid_has_state): ... this. Add new parameter "warn" and handle it. (linux_proc_pid_is_gone): New function. (linux_proc_pid_is_stopped): Adjust. (linux_proc_pid_is_zombie_maybe_warn) (linux_proc_pid_is_zombie_nowarn): New functions. (linux_proc_pid_is_zombie): Use linux_proc_pid_is_zombie_maybe_warn. (linux_proc_attach_tgid_threads): New function. * nat/linux-procfs.h (linux_proc_get_tgid): Update comment. (linux_proc_get_tracerpid): Rename to ... (linux_proc_get_tracerpid_nowarn): ... this, and update comment. (linux_proc_pid_is_gone): New declaration. (linux_proc_pid_is_zombie): Update comment. (linux_proc_pid_is_zombie_nowarn): New declaration. (linux_proc_attach_lwp_func): New typedef. (linux_proc_attach_tgid_threads): New declaration. * nat/linux-ptrace.c (linux_ptrace_attach_fail_reason): Adjust to use nowarn functions. (linux_ptrace_attach_fail_reason_string): Move here from gdbserver/linux-low.c and rename. (ptrace_supports_feature): If the current ptrace options are not known yet, check them now, instead of asserting. * nat/linux-ptrace.h (linux_ptrace_attach_fail_reason_string): Declare.
2014-12-16 17:12:24 +01:00
int err;
if (debug_threads)
debug_printf ("Found new lwp %d\n", lwpid);
gdbserver/linux-low: turn process/thread addition/deletion ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'new_process', 'delete_process', 'new_thread', 'delete_thread', and 'new_fork' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <add_linux_process> <add_lwp> <delete_lwp> <attach_lwp> <detach_one_lwp> <check_zombie_leaders> <filter_exit_event> <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. * linux-low.cc (delete_lwp): Turn into... (linux_process_target::delete_lwp): ...this. (linux_process_target::low_delete_thread): Define. (linux_add_process): Turn into... (linux_process_target::add_linux_process): ...this. (linux_process_target::low_new_process): Define. (linux_process_target::low_delete_process): Define. (linux_process_target::low_new_fork): Define. (add_lwp): Turn into... (linux_process_target::add_lwp): ...this. (linux_process_target::low_new_thread): Define. (linux_attach_lwp): Turn into... (linux_process_target::attach_lwp): ...this. (linux_detach_one_lwp): Turn into... (linux_process_target::detach_one_lwp): ...this. (linux_detach_lwp_callback): Remove and inline... (linux_process_target::detach): ...here. (check_zombie_leaders): Turn into... (linux_process_target::check_zombie_leaders): ...this. (filter_exit_event): Turn into... (linux_process_target::filter_exit_event): ...this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::create_inferior) (attach_proc_task_lwp_callback) (linux_process_target::attach) (linux_process_target::detach) (linux_process_target::mourn) * thread-db.cc (attach_thread) * linux-x86-low.cc (class x86_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (x86_linux_new_process): Turn into... (x86_target::low_new_process): ...this. (x86_linux_delete_process): Turn into... (x86_target::low_delete_process): ...this. (x86_target::low_new_thread): Define. (x86_target::low_delete_thread): Define. (x86_linux_new_fork): Turn into... (x86_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (aarch64_linux_new_process): Turn into... (aarch64_target::low_new_process): ...this. (aarch64_linux_delete_process): Turn into... (aarch64_target::low_delete_process): ...this. (aarch64_target::low_new_thread): Define. (aarch64_target::low_delete_thread): Define. (aarch64_linux_new_fork): Turn into... (aarch64_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (arm_new_process): Turn into... (arm_target::low_new_process): ...this. (arm_delete_process): Turn into... (arm_target::low_delete_process): ...this. (arm_new_thread): Turn into... (arm_target::low_new_thread): ...this. (arm_delete_thread): Turn into... (arm_target::low_delete_thread): ...this. (arm_new_fork): Turn into... (arm_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (mips_linux_new_process): Turn into... (mips_target::low_new_process): ...this. (mips_linux_delete_process): Turn into... (mips_target::low_delete_process): ...this. (mips_linux_new_thread): Turn into... (mips_target::low_new_thread): ...this. (mips_linux_delete_thread): Turn into... (mips_target::low_delete_thread): ...this. (mips_linux_new_fork): Turn into... (mips_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:28 +02:00
err = the_linux_target->attach_lwp (ptid);
Linux: on attach, attach to lwps listed under /proc/$pid/task/ ... instead of relying on libthread_db. I wrote a test that attaches to a program that constantly spawns short-lived threads, which exposed several issues. This is one of them. On Linux, we need to attach to all threads of a process (thread group) individually. We currently rely on libthread_db to list the threads, but that is problematic, because libthread_db relies on reading data structures out of the inferior (which may well be corrupted). If threads are being created or exiting just while we try to attach, we may trip on inconsistencies in the inferior's thread list. To work around that, when we see a seemingly corrupt list, we currently retry a few times: static void thread_db_find_new_threads_2 (ptid_t ptid, int until_no_new) { ... if (until_no_new) { /* Require 4 successive iterations which do not find any new threads. The 4 is a heuristic: there is an inherent race here, and I have seen that 2 iterations in a row are not always sufficient to "capture" all threads. */ ... That heuristic may well fail, and when it does, we end up with threads in the program that aren't under GDB's control. That's obviously bad and results in quite mistifying failures, like e.g., the process dying for seeminly no reason when a thread that wasn't attached trips on a breakpoint. There's really no reason to rely on libthread_db for this nowadays when we have /proc mounted. In that case, which is the usual case, we can list the LWPs from /proc/PID/task/. In fact, GDBserver is already doing this. The patch factors out that code that knows to walk the task/ directory out of GDBserver, and makes GDB use it too. Like GDBserver, the patch makes GDB attach to LWPs and _not_ wait for them to stop immediately. Instead, we just tag the LWP as having an expected stop. Because we can only set the ptrace options when the thread stops, we need a new flag in the lwp structure to keep track of whether we've already set the ptrace options, just like in GDBserver. Note that nothing issues any ptrace command to the threads between the PTRACE_ATTACH and the stop, so this is safe (unlike one scenario described in gdbserver's linux-low.c). When we attach to a program that has threads exiting while we attach, it's easy to race with a thread just exiting as we try to attach to it, like: #1 - get current list of threads #2 - attach to each listed thread #3 - ooops, attach failed, thread is already gone As this is pretty normal, we shouldn't be issuing a scary warning in step #3. When #3 happens, PTRACE_ATTACH usually fails with ESRCH, but sometimes we'll see EPERM as well. That happens when the kernel still has the thread in its task list, but the thread is marked as dead. Unfortunately, EPERM is ambiguous and we'll get it also on other scenarios where the thread isn't dead, and in those cases, it's useful to get a warning. To distiguish the cases, when we get an EPERM failure, we open /proc/PID/status, and check the thread's state -- if the /proc file no longer exists, or the state is "Z (Zombie)" or "X (Dead)", we ignore the EPERM error silently; otherwise, we'll warn. Unfortunately, there seems to be a kernel race here. Sometimes I get EPERM, and then the /proc state still indicates "R (Running)"... If we wait a bit and retry, we do end up seeing X or Z state, or get an ESRCH. I thought of making GDB retry the attach a few times, but even with a 500ms wait and 4 retries, I still see the warning sometimes. I haven't been able to identify the kernel path that causes this yet, but in any case, it looks like a kernel bug to me. As this just results failure to suppress a warning that we've been printing since about forever anyway, I'm just making the test cope with it, and issue an XFAIL. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (linux_attach_fail_reason_string): Move to nat/linux-ptrace.c, and rename. (linux_attach_lwp): Update comment. (attach_proc_task_lwp_callback): New function. (linux_attach): Adjust to rename and use linux_proc_attach_tgid_threads. (linux_attach_fail_reason_string): Delete declaration. gdb/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-nat.c (attach_proc_task_lwp_callback): New function. (linux_nat_attach): Use linux_proc_attach_tgid_threads. (wait_lwp, linux_nat_filter_event): If not set yet, set the lwp's ptrace option flags. * linux-nat.h (struct lwp_info) <must_set_ptrace_flags>: New field. * nat/linux-procfs.c: Include <dirent.h>. (linux_proc_get_int): New parameter "warn". Handle it. (linux_proc_get_tgid): Adjust. (linux_proc_get_tracerpid): Rename to ... (linux_proc_get_tracerpid_nowarn): ... this. (linux_proc_pid_get_state): New function, factored out from (linux_proc_pid_has_state): ... this. Add new parameter "warn" and handle it. (linux_proc_pid_is_gone): New function. (linux_proc_pid_is_stopped): Adjust. (linux_proc_pid_is_zombie_maybe_warn) (linux_proc_pid_is_zombie_nowarn): New functions. (linux_proc_pid_is_zombie): Use linux_proc_pid_is_zombie_maybe_warn. (linux_proc_attach_tgid_threads): New function. * nat/linux-procfs.h (linux_proc_get_tgid): Update comment. (linux_proc_get_tracerpid): Rename to ... (linux_proc_get_tracerpid_nowarn): ... this, and update comment. (linux_proc_pid_is_gone): New declaration. (linux_proc_pid_is_zombie): Update comment. (linux_proc_pid_is_zombie_nowarn): New declaration. (linux_proc_attach_lwp_func): New typedef. (linux_proc_attach_tgid_threads): New declaration. * nat/linux-ptrace.c (linux_ptrace_attach_fail_reason): Adjust to use nowarn functions. (linux_ptrace_attach_fail_reason_string): Move here from gdbserver/linux-low.c and rename. (ptrace_supports_feature): If the current ptrace options are not known yet, check them now, instead of asserting. * nat/linux-ptrace.h (linux_ptrace_attach_fail_reason_string): Declare.
2014-12-16 17:12:24 +01:00
/* Be quiet if we simply raced with the thread exiting. EPERM
is returned if the thread's task still exists, and is marked
as exited or zombie, as well as other conditions, so in that
case, confirm the status in /proc/PID/status. */
if (err == ESRCH
|| (err == EPERM && linux_proc_pid_is_gone (lwpid)))
{
if (debug_threads)
{
debug_printf ("Cannot attach to lwp %d: "
"thread is gone (%d: %s)\n",
lwpid, err, safe_strerror (err));
Linux: on attach, attach to lwps listed under /proc/$pid/task/ ... instead of relying on libthread_db. I wrote a test that attaches to a program that constantly spawns short-lived threads, which exposed several issues. This is one of them. On Linux, we need to attach to all threads of a process (thread group) individually. We currently rely on libthread_db to list the threads, but that is problematic, because libthread_db relies on reading data structures out of the inferior (which may well be corrupted). If threads are being created or exiting just while we try to attach, we may trip on inconsistencies in the inferior's thread list. To work around that, when we see a seemingly corrupt list, we currently retry a few times: static void thread_db_find_new_threads_2 (ptid_t ptid, int until_no_new) { ... if (until_no_new) { /* Require 4 successive iterations which do not find any new threads. The 4 is a heuristic: there is an inherent race here, and I have seen that 2 iterations in a row are not always sufficient to "capture" all threads. */ ... That heuristic may well fail, and when it does, we end up with threads in the program that aren't under GDB's control. That's obviously bad and results in quite mistifying failures, like e.g., the process dying for seeminly no reason when a thread that wasn't attached trips on a breakpoint. There's really no reason to rely on libthread_db for this nowadays when we have /proc mounted. In that case, which is the usual case, we can list the LWPs from /proc/PID/task/. In fact, GDBserver is already doing this. The patch factors out that code that knows to walk the task/ directory out of GDBserver, and makes GDB use it too. Like GDBserver, the patch makes GDB attach to LWPs and _not_ wait for them to stop immediately. Instead, we just tag the LWP as having an expected stop. Because we can only set the ptrace options when the thread stops, we need a new flag in the lwp structure to keep track of whether we've already set the ptrace options, just like in GDBserver. Note that nothing issues any ptrace command to the threads between the PTRACE_ATTACH and the stop, so this is safe (unlike one scenario described in gdbserver's linux-low.c). When we attach to a program that has threads exiting while we attach, it's easy to race with a thread just exiting as we try to attach to it, like: #1 - get current list of threads #2 - attach to each listed thread #3 - ooops, attach failed, thread is already gone As this is pretty normal, we shouldn't be issuing a scary warning in step #3. When #3 happens, PTRACE_ATTACH usually fails with ESRCH, but sometimes we'll see EPERM as well. That happens when the kernel still has the thread in its task list, but the thread is marked as dead. Unfortunately, EPERM is ambiguous and we'll get it also on other scenarios where the thread isn't dead, and in those cases, it's useful to get a warning. To distiguish the cases, when we get an EPERM failure, we open /proc/PID/status, and check the thread's state -- if the /proc file no longer exists, or the state is "Z (Zombie)" or "X (Dead)", we ignore the EPERM error silently; otherwise, we'll warn. Unfortunately, there seems to be a kernel race here. Sometimes I get EPERM, and then the /proc state still indicates "R (Running)"... If we wait a bit and retry, we do end up seeing X or Z state, or get an ESRCH. I thought of making GDB retry the attach a few times, but even with a 500ms wait and 4 retries, I still see the warning sometimes. I haven't been able to identify the kernel path that causes this yet, but in any case, it looks like a kernel bug to me. As this just results failure to suppress a warning that we've been printing since about forever anyway, I'm just making the test cope with it, and issue an XFAIL. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (linux_attach_fail_reason_string): Move to nat/linux-ptrace.c, and rename. (linux_attach_lwp): Update comment. (attach_proc_task_lwp_callback): New function. (linux_attach): Adjust to rename and use linux_proc_attach_tgid_threads. (linux_attach_fail_reason_string): Delete declaration. gdb/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-nat.c (attach_proc_task_lwp_callback): New function. (linux_nat_attach): Use linux_proc_attach_tgid_threads. (wait_lwp, linux_nat_filter_event): If not set yet, set the lwp's ptrace option flags. * linux-nat.h (struct lwp_info) <must_set_ptrace_flags>: New field. * nat/linux-procfs.c: Include <dirent.h>. (linux_proc_get_int): New parameter "warn". Handle it. (linux_proc_get_tgid): Adjust. (linux_proc_get_tracerpid): Rename to ... (linux_proc_get_tracerpid_nowarn): ... this. (linux_proc_pid_get_state): New function, factored out from (linux_proc_pid_has_state): ... this. Add new parameter "warn" and handle it. (linux_proc_pid_is_gone): New function. (linux_proc_pid_is_stopped): Adjust. (linux_proc_pid_is_zombie_maybe_warn) (linux_proc_pid_is_zombie_nowarn): New functions. (linux_proc_pid_is_zombie): Use linux_proc_pid_is_zombie_maybe_warn. (linux_proc_attach_tgid_threads): New function. * nat/linux-procfs.h (linux_proc_get_tgid): Update comment. (linux_proc_get_tracerpid): Rename to ... (linux_proc_get_tracerpid_nowarn): ... this, and update comment. (linux_proc_pid_is_gone): New declaration. (linux_proc_pid_is_zombie): Update comment. (linux_proc_pid_is_zombie_nowarn): New declaration. (linux_proc_attach_lwp_func): New typedef. (linux_proc_attach_tgid_threads): New declaration. * nat/linux-ptrace.c (linux_ptrace_attach_fail_reason): Adjust to use nowarn functions. (linux_ptrace_attach_fail_reason_string): Move here from gdbserver/linux-low.c and rename. (ptrace_supports_feature): If the current ptrace options are not known yet, check them now, instead of asserting. * nat/linux-ptrace.h (linux_ptrace_attach_fail_reason_string): Declare.
2014-12-16 17:12:24 +01:00
}
}
else if (err != 0)
{
std::string reason
= linux_ptrace_attach_fail_reason_string (ptid, err);
warning (_("Cannot attach to lwp %d: %s"), lwpid, reason.c_str ());
Linux: on attach, attach to lwps listed under /proc/$pid/task/ ... instead of relying on libthread_db. I wrote a test that attaches to a program that constantly spawns short-lived threads, which exposed several issues. This is one of them. On Linux, we need to attach to all threads of a process (thread group) individually. We currently rely on libthread_db to list the threads, but that is problematic, because libthread_db relies on reading data structures out of the inferior (which may well be corrupted). If threads are being created or exiting just while we try to attach, we may trip on inconsistencies in the inferior's thread list. To work around that, when we see a seemingly corrupt list, we currently retry a few times: static void thread_db_find_new_threads_2 (ptid_t ptid, int until_no_new) { ... if (until_no_new) { /* Require 4 successive iterations which do not find any new threads. The 4 is a heuristic: there is an inherent race here, and I have seen that 2 iterations in a row are not always sufficient to "capture" all threads. */ ... That heuristic may well fail, and when it does, we end up with threads in the program that aren't under GDB's control. That's obviously bad and results in quite mistifying failures, like e.g., the process dying for seeminly no reason when a thread that wasn't attached trips on a breakpoint. There's really no reason to rely on libthread_db for this nowadays when we have /proc mounted. In that case, which is the usual case, we can list the LWPs from /proc/PID/task/. In fact, GDBserver is already doing this. The patch factors out that code that knows to walk the task/ directory out of GDBserver, and makes GDB use it too. Like GDBserver, the patch makes GDB attach to LWPs and _not_ wait for them to stop immediately. Instead, we just tag the LWP as having an expected stop. Because we can only set the ptrace options when the thread stops, we need a new flag in the lwp structure to keep track of whether we've already set the ptrace options, just like in GDBserver. Note that nothing issues any ptrace command to the threads between the PTRACE_ATTACH and the stop, so this is safe (unlike one scenario described in gdbserver's linux-low.c). When we attach to a program that has threads exiting while we attach, it's easy to race with a thread just exiting as we try to attach to it, like: #1 - get current list of threads #2 - attach to each listed thread #3 - ooops, attach failed, thread is already gone As this is pretty normal, we shouldn't be issuing a scary warning in step #3. When #3 happens, PTRACE_ATTACH usually fails with ESRCH, but sometimes we'll see EPERM as well. That happens when the kernel still has the thread in its task list, but the thread is marked as dead. Unfortunately, EPERM is ambiguous and we'll get it also on other scenarios where the thread isn't dead, and in those cases, it's useful to get a warning. To distiguish the cases, when we get an EPERM failure, we open /proc/PID/status, and check the thread's state -- if the /proc file no longer exists, or the state is "Z (Zombie)" or "X (Dead)", we ignore the EPERM error silently; otherwise, we'll warn. Unfortunately, there seems to be a kernel race here. Sometimes I get EPERM, and then the /proc state still indicates "R (Running)"... If we wait a bit and retry, we do end up seeing X or Z state, or get an ESRCH. I thought of making GDB retry the attach a few times, but even with a 500ms wait and 4 retries, I still see the warning sometimes. I haven't been able to identify the kernel path that causes this yet, but in any case, it looks like a kernel bug to me. As this just results failure to suppress a warning that we've been printing since about forever anyway, I'm just making the test cope with it, and issue an XFAIL. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (linux_attach_fail_reason_string): Move to nat/linux-ptrace.c, and rename. (linux_attach_lwp): Update comment. (attach_proc_task_lwp_callback): New function. (linux_attach): Adjust to rename and use linux_proc_attach_tgid_threads. (linux_attach_fail_reason_string): Delete declaration. gdb/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-nat.c (attach_proc_task_lwp_callback): New function. (linux_nat_attach): Use linux_proc_attach_tgid_threads. (wait_lwp, linux_nat_filter_event): If not set yet, set the lwp's ptrace option flags. * linux-nat.h (struct lwp_info) <must_set_ptrace_flags>: New field. * nat/linux-procfs.c: Include <dirent.h>. (linux_proc_get_int): New parameter "warn". Handle it. (linux_proc_get_tgid): Adjust. (linux_proc_get_tracerpid): Rename to ... (linux_proc_get_tracerpid_nowarn): ... this. (linux_proc_pid_get_state): New function, factored out from (linux_proc_pid_has_state): ... this. Add new parameter "warn" and handle it. (linux_proc_pid_is_gone): New function. (linux_proc_pid_is_stopped): Adjust. (linux_proc_pid_is_zombie_maybe_warn) (linux_proc_pid_is_zombie_nowarn): New functions. (linux_proc_pid_is_zombie): Use linux_proc_pid_is_zombie_maybe_warn. (linux_proc_attach_tgid_threads): New function. * nat/linux-procfs.h (linux_proc_get_tgid): Update comment. (linux_proc_get_tracerpid): Rename to ... (linux_proc_get_tracerpid_nowarn): ... this, and update comment. (linux_proc_pid_is_gone): New declaration. (linux_proc_pid_is_zombie): Update comment. (linux_proc_pid_is_zombie_nowarn): New declaration. (linux_proc_attach_lwp_func): New typedef. (linux_proc_attach_tgid_threads): New declaration. * nat/linux-ptrace.c (linux_ptrace_attach_fail_reason): Adjust to use nowarn functions. (linux_ptrace_attach_fail_reason_string): Move here from gdbserver/linux-low.c and rename. (ptrace_supports_feature): If the current ptrace options are not known yet, check them now, instead of asserting. * nat/linux-ptrace.h (linux_ptrace_attach_fail_reason_string): Declare.
2014-12-16 17:12:24 +01:00
}
return 1;
}
return 0;
}
static void async_file_mark (void);
/* Attach to PID. If PID is the tgid, attach to it and all
of its threads. */
int
linux_process_target::attach (unsigned long pid)
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
{
struct process_info *proc;
struct thread_info *initial_thread;
ptid_t ptid = ptid_t (pid, pid, 0);
PR server/16255: gdbserver cannot attach to a second inferior that is multi-threaded. On Linux, we need to explicitly ptrace attach to all lwps of a process. Because GDB might not be connected yet when an attach is requested, and thus it may not be possible to activate thread_db, as that requires access to symbols (IOW, gdbserver --attach), a while ago we make linux_attach loop over the lwps as listed by /proc/PID/task to find the lwps to attach to. linux_attach_lwp_1 has: ... if (initial) /* If lwp is the tgid, we handle adding existing threads later. Otherwise we just add lwp without bothering about any other threads. */ ptid = ptid_build (lwpid, lwpid, 0); else { /* Note that extracting the pid from the current inferior is safe, since we're always called in the context of the same process as this new thread. */ int pid = pid_of (current_inferior); ptid = ptid_build (pid, lwpid, 0); } That "safe" comment referred to linux_attach_lwp being called by thread-db.c. But this was clearly missed when a new call to linux_attach_lwp_1 was added to linux_attach. As a result, current_inferior will be set to some random process, and non-initial lwps of the second inferior get assigned the pid of the wrong inferior. E.g., in the case of attaching to two inferiors, for the second inferior (and so on), non-initial lwps of the second inferior get assigned the pid of the first inferior. This doesn't trigger on the first inferior, when current_inferior is NULL, add_thread switches the current inferior to the newly added thread. Rather than making linux_attach switch current_inferior temporarily (thus avoiding further reliance on global state), or making linux_attach_lwp_1 get the tgid from /proc, which add extra syscalls, and will be wrong in case of the user having originally attached directly to a non-tgid lwp, and then that lwp spawning new clones (the ptid.pid field of further new clones should be the same as the original lwp's pid, which is not the tgid), we note that callers of linux_attach_lwp/linux_attach_lwp_1 always have the right pid handy already, so they can pass it down along with the lwpid. The only other reason for the "initial" parameter is to error out instead of warn in case of attach failure, when we're first attaching to a process. There are only three callers of linux_attach_lwp/linux_attach_lwp_1, and each wants to print a different warn/error string, so we can just move the error/warn out of linux_attach_lwp_1 to the callers, thus getting rid of the "initial" parameter. There really nothing gdbserver-specific about attaching to two threaded processes, so this adds a new test under gdb.multi/. The test passes cleanly against the native GNU/Linux target, but fails/triggers the bug against GDBserver (before the patch), with the native-extended-remote board (as plain remote doesn't support multi-process). Tested on x86_64 Fedora 17, with the native-extended-gdbserver board. gdb/gdbserver/ 2014-04-25 Pedro Alves <palves@redhat.com> PR server/16255 * linux-low.c (linux_attach_fail_reason_string): New function. (linux_attach_lwp): Delete. (linux_attach_lwp_1): Rename to ... (linux_attach_lwp): ... this. Take a ptid instead of a pid as argument. Remove "initial" parameter. Return int instead of void. Don't error or warn here. (linux_attach): Adjust to call linux_attach_lwp. Call error on failure to attach to the tgid. Call warning when failing to attach to an lwp. * linux-low.h (linux_attach_lwp): Take a ptid instead of a pid as argument. Remove "initial" parameter. Return int instead of void. Don't error or warn here. (linux_attach_fail_reason_string): New declaration. * thread-db.c (attach_thread): Adjust to linux_attach_lwp's interface change. Use linux_attach_fail_reason_string. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> PR server/16255 * common/linux-ptrace.c (linux_ptrace_attach_warnings): Rename to ... (linux_ptrace_attach_fail_reason): ... this. Remove "warning: " and newline from built string. * common/linux-ptrace.h (linux_ptrace_attach_warnings): Rename to ... (linux_ptrace_attach_fail_reason): ... this. * linux-nat.c (linux_nat_attach): Adjust to use linux_ptrace_attach_fail_reason. gdb/testsuite/ 2014-04-25 Simon Marchi <simon.marchi@ericsson.com> Pedro Alves <palves@redhat.com> PR server/16255 * gdb.multi/multi-attach.c: New file. * gdb.multi/multi-attach.exp: New file.
2014-04-25 20:07:33 +02:00
int err;
gdbserver/linux-low: turn process/thread addition/deletion ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'new_process', 'delete_process', 'new_thread', 'delete_thread', and 'new_fork' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <add_linux_process> <add_lwp> <delete_lwp> <attach_lwp> <detach_one_lwp> <check_zombie_leaders> <filter_exit_event> <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. * linux-low.cc (delete_lwp): Turn into... (linux_process_target::delete_lwp): ...this. (linux_process_target::low_delete_thread): Define. (linux_add_process): Turn into... (linux_process_target::add_linux_process): ...this. (linux_process_target::low_new_process): Define. (linux_process_target::low_delete_process): Define. (linux_process_target::low_new_fork): Define. (add_lwp): Turn into... (linux_process_target::add_lwp): ...this. (linux_process_target::low_new_thread): Define. (linux_attach_lwp): Turn into... (linux_process_target::attach_lwp): ...this. (linux_detach_one_lwp): Turn into... (linux_process_target::detach_one_lwp): ...this. (linux_detach_lwp_callback): Remove and inline... (linux_process_target::detach): ...here. (check_zombie_leaders): Turn into... (linux_process_target::check_zombie_leaders): ...this. (filter_exit_event): Turn into... (linux_process_target::filter_exit_event): ...this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::create_inferior) (attach_proc_task_lwp_callback) (linux_process_target::attach) (linux_process_target::detach) (linux_process_target::mourn) * thread-db.cc (attach_thread) * linux-x86-low.cc (class x86_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (x86_linux_new_process): Turn into... (x86_target::low_new_process): ...this. (x86_linux_delete_process): Turn into... (x86_target::low_delete_process): ...this. (x86_target::low_new_thread): Define. (x86_target::low_delete_thread): Define. (x86_linux_new_fork): Turn into... (x86_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (aarch64_linux_new_process): Turn into... (aarch64_target::low_new_process): ...this. (aarch64_linux_delete_process): Turn into... (aarch64_target::low_delete_process): ...this. (aarch64_target::low_new_thread): Define. (aarch64_target::low_delete_thread): Define. (aarch64_linux_new_fork): Turn into... (aarch64_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (arm_new_process): Turn into... (arm_target::low_new_process): ...this. (arm_delete_process): Turn into... (arm_target::low_delete_process): ...this. (arm_new_thread): Turn into... (arm_target::low_new_thread): ...this. (arm_delete_thread): Turn into... (arm_target::low_delete_thread): ...this. (arm_new_fork): Turn into... (arm_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (mips_linux_new_process): Turn into... (mips_target::low_new_process): ...this. (mips_linux_delete_process): Turn into... (mips_target::low_delete_process): ...this. (mips_linux_new_thread): Turn into... (mips_target::low_new_thread): ...this. (mips_linux_delete_thread): Turn into... (mips_target::low_delete_thread): ...this. (mips_linux_new_fork): Turn into... (mips_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:28 +02:00
proc = add_linux_process (pid, 1);
/* Attach to PID. We will check for other threads
soon. */
gdbserver/linux-low: turn process/thread addition/deletion ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'new_process', 'delete_process', 'new_thread', 'delete_thread', and 'new_fork' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <add_linux_process> <add_lwp> <delete_lwp> <attach_lwp> <detach_one_lwp> <check_zombie_leaders> <filter_exit_event> <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. * linux-low.cc (delete_lwp): Turn into... (linux_process_target::delete_lwp): ...this. (linux_process_target::low_delete_thread): Define. (linux_add_process): Turn into... (linux_process_target::add_linux_process): ...this. (linux_process_target::low_new_process): Define. (linux_process_target::low_delete_process): Define. (linux_process_target::low_new_fork): Define. (add_lwp): Turn into... (linux_process_target::add_lwp): ...this. (linux_process_target::low_new_thread): Define. (linux_attach_lwp): Turn into... (linux_process_target::attach_lwp): ...this. (linux_detach_one_lwp): Turn into... (linux_process_target::detach_one_lwp): ...this. (linux_detach_lwp_callback): Remove and inline... (linux_process_target::detach): ...here. (check_zombie_leaders): Turn into... (linux_process_target::check_zombie_leaders): ...this. (filter_exit_event): Turn into... (linux_process_target::filter_exit_event): ...this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::create_inferior) (attach_proc_task_lwp_callback) (linux_process_target::attach) (linux_process_target::detach) (linux_process_target::mourn) * thread-db.cc (attach_thread) * linux-x86-low.cc (class x86_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (x86_linux_new_process): Turn into... (x86_target::low_new_process): ...this. (x86_linux_delete_process): Turn into... (x86_target::low_delete_process): ...this. (x86_target::low_new_thread): Define. (x86_target::low_delete_thread): Define. (x86_linux_new_fork): Turn into... (x86_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (aarch64_linux_new_process): Turn into... (aarch64_target::low_new_process): ...this. (aarch64_linux_delete_process): Turn into... (aarch64_target::low_delete_process): ...this. (aarch64_target::low_new_thread): Define. (aarch64_target::low_delete_thread): Define. (aarch64_linux_new_fork): Turn into... (aarch64_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (arm_new_process): Turn into... (arm_target::low_new_process): ...this. (arm_delete_process): Turn into... (arm_target::low_delete_process): ...this. (arm_new_thread): Turn into... (arm_target::low_new_thread): ...this. (arm_delete_thread): Turn into... (arm_target::low_delete_thread): ...this. (arm_new_fork): Turn into... (arm_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (mips_linux_new_process): Turn into... (mips_target::low_new_process): ...this. (mips_linux_delete_process): Turn into... (mips_target::low_delete_process): ...this. (mips_linux_new_thread): Turn into... (mips_target::low_new_thread): ...this. (mips_linux_delete_thread): Turn into... (mips_target::low_delete_thread): ...this. (mips_linux_new_fork): Turn into... (mips_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:28 +02:00
err = attach_lwp (ptid);
PR server/16255: gdbserver cannot attach to a second inferior that is multi-threaded. On Linux, we need to explicitly ptrace attach to all lwps of a process. Because GDB might not be connected yet when an attach is requested, and thus it may not be possible to activate thread_db, as that requires access to symbols (IOW, gdbserver --attach), a while ago we make linux_attach loop over the lwps as listed by /proc/PID/task to find the lwps to attach to. linux_attach_lwp_1 has: ... if (initial) /* If lwp is the tgid, we handle adding existing threads later. Otherwise we just add lwp without bothering about any other threads. */ ptid = ptid_build (lwpid, lwpid, 0); else { /* Note that extracting the pid from the current inferior is safe, since we're always called in the context of the same process as this new thread. */ int pid = pid_of (current_inferior); ptid = ptid_build (pid, lwpid, 0); } That "safe" comment referred to linux_attach_lwp being called by thread-db.c. But this was clearly missed when a new call to linux_attach_lwp_1 was added to linux_attach. As a result, current_inferior will be set to some random process, and non-initial lwps of the second inferior get assigned the pid of the wrong inferior. E.g., in the case of attaching to two inferiors, for the second inferior (and so on), non-initial lwps of the second inferior get assigned the pid of the first inferior. This doesn't trigger on the first inferior, when current_inferior is NULL, add_thread switches the current inferior to the newly added thread. Rather than making linux_attach switch current_inferior temporarily (thus avoiding further reliance on global state), or making linux_attach_lwp_1 get the tgid from /proc, which add extra syscalls, and will be wrong in case of the user having originally attached directly to a non-tgid lwp, and then that lwp spawning new clones (the ptid.pid field of further new clones should be the same as the original lwp's pid, which is not the tgid), we note that callers of linux_attach_lwp/linux_attach_lwp_1 always have the right pid handy already, so they can pass it down along with the lwpid. The only other reason for the "initial" parameter is to error out instead of warn in case of attach failure, when we're first attaching to a process. There are only three callers of linux_attach_lwp/linux_attach_lwp_1, and each wants to print a different warn/error string, so we can just move the error/warn out of linux_attach_lwp_1 to the callers, thus getting rid of the "initial" parameter. There really nothing gdbserver-specific about attaching to two threaded processes, so this adds a new test under gdb.multi/. The test passes cleanly against the native GNU/Linux target, but fails/triggers the bug against GDBserver (before the patch), with the native-extended-remote board (as plain remote doesn't support multi-process). Tested on x86_64 Fedora 17, with the native-extended-gdbserver board. gdb/gdbserver/ 2014-04-25 Pedro Alves <palves@redhat.com> PR server/16255 * linux-low.c (linux_attach_fail_reason_string): New function. (linux_attach_lwp): Delete. (linux_attach_lwp_1): Rename to ... (linux_attach_lwp): ... this. Take a ptid instead of a pid as argument. Remove "initial" parameter. Return int instead of void. Don't error or warn here. (linux_attach): Adjust to call linux_attach_lwp. Call error on failure to attach to the tgid. Call warning when failing to attach to an lwp. * linux-low.h (linux_attach_lwp): Take a ptid instead of a pid as argument. Remove "initial" parameter. Return int instead of void. Don't error or warn here. (linux_attach_fail_reason_string): New declaration. * thread-db.c (attach_thread): Adjust to linux_attach_lwp's interface change. Use linux_attach_fail_reason_string. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> PR server/16255 * common/linux-ptrace.c (linux_ptrace_attach_warnings): Rename to ... (linux_ptrace_attach_fail_reason): ... this. Remove "warning: " and newline from built string. * common/linux-ptrace.h (linux_ptrace_attach_warnings): Rename to ... (linux_ptrace_attach_fail_reason): ... this. * linux-nat.c (linux_nat_attach): Adjust to use linux_ptrace_attach_fail_reason. gdb/testsuite/ 2014-04-25 Simon Marchi <simon.marchi@ericsson.com> Pedro Alves <palves@redhat.com> PR server/16255 * gdb.multi/multi-attach.c: New file. * gdb.multi/multi-attach.exp: New file.
2014-04-25 20:07:33 +02:00
if (err != 0)
{
remove_process (proc);
std::string reason = linux_ptrace_attach_fail_reason_string (ptid, err);
error ("Cannot attach to process %ld: %s", pid, reason.c_str ());
}
PR server/16255: gdbserver cannot attach to a second inferior that is multi-threaded. On Linux, we need to explicitly ptrace attach to all lwps of a process. Because GDB might not be connected yet when an attach is requested, and thus it may not be possible to activate thread_db, as that requires access to symbols (IOW, gdbserver --attach), a while ago we make linux_attach loop over the lwps as listed by /proc/PID/task to find the lwps to attach to. linux_attach_lwp_1 has: ... if (initial) /* If lwp is the tgid, we handle adding existing threads later. Otherwise we just add lwp without bothering about any other threads. */ ptid = ptid_build (lwpid, lwpid, 0); else { /* Note that extracting the pid from the current inferior is safe, since we're always called in the context of the same process as this new thread. */ int pid = pid_of (current_inferior); ptid = ptid_build (pid, lwpid, 0); } That "safe" comment referred to linux_attach_lwp being called by thread-db.c. But this was clearly missed when a new call to linux_attach_lwp_1 was added to linux_attach. As a result, current_inferior will be set to some random process, and non-initial lwps of the second inferior get assigned the pid of the wrong inferior. E.g., in the case of attaching to two inferiors, for the second inferior (and so on), non-initial lwps of the second inferior get assigned the pid of the first inferior. This doesn't trigger on the first inferior, when current_inferior is NULL, add_thread switches the current inferior to the newly added thread. Rather than making linux_attach switch current_inferior temporarily (thus avoiding further reliance on global state), or making linux_attach_lwp_1 get the tgid from /proc, which add extra syscalls, and will be wrong in case of the user having originally attached directly to a non-tgid lwp, and then that lwp spawning new clones (the ptid.pid field of further new clones should be the same as the original lwp's pid, which is not the tgid), we note that callers of linux_attach_lwp/linux_attach_lwp_1 always have the right pid handy already, so they can pass it down along with the lwpid. The only other reason for the "initial" parameter is to error out instead of warn in case of attach failure, when we're first attaching to a process. There are only three callers of linux_attach_lwp/linux_attach_lwp_1, and each wants to print a different warn/error string, so we can just move the error/warn out of linux_attach_lwp_1 to the callers, thus getting rid of the "initial" parameter. There really nothing gdbserver-specific about attaching to two threaded processes, so this adds a new test under gdb.multi/. The test passes cleanly against the native GNU/Linux target, but fails/triggers the bug against GDBserver (before the patch), with the native-extended-remote board (as plain remote doesn't support multi-process). Tested on x86_64 Fedora 17, with the native-extended-gdbserver board. gdb/gdbserver/ 2014-04-25 Pedro Alves <palves@redhat.com> PR server/16255 * linux-low.c (linux_attach_fail_reason_string): New function. (linux_attach_lwp): Delete. (linux_attach_lwp_1): Rename to ... (linux_attach_lwp): ... this. Take a ptid instead of a pid as argument. Remove "initial" parameter. Return int instead of void. Don't error or warn here. (linux_attach): Adjust to call linux_attach_lwp. Call error on failure to attach to the tgid. Call warning when failing to attach to an lwp. * linux-low.h (linux_attach_lwp): Take a ptid instead of a pid as argument. Remove "initial" parameter. Return int instead of void. Don't error or warn here. (linux_attach_fail_reason_string): New declaration. * thread-db.c (attach_thread): Adjust to linux_attach_lwp's interface change. Use linux_attach_fail_reason_string. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> PR server/16255 * common/linux-ptrace.c (linux_ptrace_attach_warnings): Rename to ... (linux_ptrace_attach_fail_reason): ... this. Remove "warning: " and newline from built string. * common/linux-ptrace.h (linux_ptrace_attach_warnings): Rename to ... (linux_ptrace_attach_fail_reason): ... this. * linux-nat.c (linux_nat_attach): Adjust to use linux_ptrace_attach_fail_reason. gdb/testsuite/ 2014-04-25 Simon Marchi <simon.marchi@ericsson.com> Pedro Alves <palves@redhat.com> PR server/16255 * gdb.multi/multi-attach.c: New file. * gdb.multi/multi-attach.exp: New file.
2014-04-25 20:07:33 +02:00
/* Don't ignore the initial SIGSTOP if we just attached to this
process. It will be collected by wait shortly. */
initial_thread = find_thread_ptid (ptid_t (pid, pid, 0));
initial_thread->last_resume_kind = resume_stop;
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
Linux: on attach, attach to lwps listed under /proc/$pid/task/ ... instead of relying on libthread_db. I wrote a test that attaches to a program that constantly spawns short-lived threads, which exposed several issues. This is one of them. On Linux, we need to attach to all threads of a process (thread group) individually. We currently rely on libthread_db to list the threads, but that is problematic, because libthread_db relies on reading data structures out of the inferior (which may well be corrupted). If threads are being created or exiting just while we try to attach, we may trip on inconsistencies in the inferior's thread list. To work around that, when we see a seemingly corrupt list, we currently retry a few times: static void thread_db_find_new_threads_2 (ptid_t ptid, int until_no_new) { ... if (until_no_new) { /* Require 4 successive iterations which do not find any new threads. The 4 is a heuristic: there is an inherent race here, and I have seen that 2 iterations in a row are not always sufficient to "capture" all threads. */ ... That heuristic may well fail, and when it does, we end up with threads in the program that aren't under GDB's control. That's obviously bad and results in quite mistifying failures, like e.g., the process dying for seeminly no reason when a thread that wasn't attached trips on a breakpoint. There's really no reason to rely on libthread_db for this nowadays when we have /proc mounted. In that case, which is the usual case, we can list the LWPs from /proc/PID/task/. In fact, GDBserver is already doing this. The patch factors out that code that knows to walk the task/ directory out of GDBserver, and makes GDB use it too. Like GDBserver, the patch makes GDB attach to LWPs and _not_ wait for them to stop immediately. Instead, we just tag the LWP as having an expected stop. Because we can only set the ptrace options when the thread stops, we need a new flag in the lwp structure to keep track of whether we've already set the ptrace options, just like in GDBserver. Note that nothing issues any ptrace command to the threads between the PTRACE_ATTACH and the stop, so this is safe (unlike one scenario described in gdbserver's linux-low.c). When we attach to a program that has threads exiting while we attach, it's easy to race with a thread just exiting as we try to attach to it, like: #1 - get current list of threads #2 - attach to each listed thread #3 - ooops, attach failed, thread is already gone As this is pretty normal, we shouldn't be issuing a scary warning in step #3. When #3 happens, PTRACE_ATTACH usually fails with ESRCH, but sometimes we'll see EPERM as well. That happens when the kernel still has the thread in its task list, but the thread is marked as dead. Unfortunately, EPERM is ambiguous and we'll get it also on other scenarios where the thread isn't dead, and in those cases, it's useful to get a warning. To distiguish the cases, when we get an EPERM failure, we open /proc/PID/status, and check the thread's state -- if the /proc file no longer exists, or the state is "Z (Zombie)" or "X (Dead)", we ignore the EPERM error silently; otherwise, we'll warn. Unfortunately, there seems to be a kernel race here. Sometimes I get EPERM, and then the /proc state still indicates "R (Running)"... If we wait a bit and retry, we do end up seeing X or Z state, or get an ESRCH. I thought of making GDB retry the attach a few times, but even with a 500ms wait and 4 retries, I still see the warning sometimes. I haven't been able to identify the kernel path that causes this yet, but in any case, it looks like a kernel bug to me. As this just results failure to suppress a warning that we've been printing since about forever anyway, I'm just making the test cope with it, and issue an XFAIL. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (linux_attach_fail_reason_string): Move to nat/linux-ptrace.c, and rename. (linux_attach_lwp): Update comment. (attach_proc_task_lwp_callback): New function. (linux_attach): Adjust to rename and use linux_proc_attach_tgid_threads. (linux_attach_fail_reason_string): Delete declaration. gdb/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-nat.c (attach_proc_task_lwp_callback): New function. (linux_nat_attach): Use linux_proc_attach_tgid_threads. (wait_lwp, linux_nat_filter_event): If not set yet, set the lwp's ptrace option flags. * linux-nat.h (struct lwp_info) <must_set_ptrace_flags>: New field. * nat/linux-procfs.c: Include <dirent.h>. (linux_proc_get_int): New parameter "warn". Handle it. (linux_proc_get_tgid): Adjust. (linux_proc_get_tracerpid): Rename to ... (linux_proc_get_tracerpid_nowarn): ... this. (linux_proc_pid_get_state): New function, factored out from (linux_proc_pid_has_state): ... this. Add new parameter "warn" and handle it. (linux_proc_pid_is_gone): New function. (linux_proc_pid_is_stopped): Adjust. (linux_proc_pid_is_zombie_maybe_warn) (linux_proc_pid_is_zombie_nowarn): New functions. (linux_proc_pid_is_zombie): Use linux_proc_pid_is_zombie_maybe_warn. (linux_proc_attach_tgid_threads): New function. * nat/linux-procfs.h (linux_proc_get_tgid): Update comment. (linux_proc_get_tracerpid): Rename to ... (linux_proc_get_tracerpid_nowarn): ... this, and update comment. (linux_proc_pid_is_gone): New declaration. (linux_proc_pid_is_zombie): Update comment. (linux_proc_pid_is_zombie_nowarn): New declaration. (linux_proc_attach_lwp_func): New typedef. (linux_proc_attach_tgid_threads): New declaration. * nat/linux-ptrace.c (linux_ptrace_attach_fail_reason): Adjust to use nowarn functions. (linux_ptrace_attach_fail_reason_string): Move here from gdbserver/linux-low.c and rename. (ptrace_supports_feature): If the current ptrace options are not known yet, check them now, instead of asserting. * nat/linux-ptrace.h (linux_ptrace_attach_fail_reason_string): Declare.
2014-12-16 17:12:24 +01:00
/* We must attach to every LWP. If /proc is mounted, use that to
find them now. On the one hand, the inferior may be using raw
clone instead of using pthreads. On the other hand, even if it
is using pthreads, GDB may not be connected yet (thread_db needs
to do symbol lookups, through qSymbol). Also, thread_db walks
structures in the inferior's address space to find the list of
threads/LWPs, and those structures may well be corrupted. Note
that once thread_db is loaded, we'll still use it to list threads
and associate pthread info with each LWP. */
linux_proc_attach_tgid_threads (pid, attach_proc_task_lwp_callback);
/* GDB will shortly read the xml target description for this
process, to figure out the process' architecture. But the target
description is only filled in when the first process/thread in
the thread group reports its initial PTRACE_ATTACH SIGSTOP. Do
that now, otherwise, if GDB is fast enough, it could read the
target description _before_ that initial stop. */
if (non_stop)
{
struct lwp_info *lwp;
int wstat, lwpid;
ptid_t pid_ptid = ptid_t (pid);
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
lwpid = wait_for_event_filtered (pid_ptid, pid_ptid, &wstat, __WALL);
gdb_assert (lwpid > 0);
lwp = find_lwp_pid (ptid_t (lwpid));
if (!WIFSTOPPED (wstat) || WSTOPSIG (wstat) != SIGSTOP)
{
lwp->status_pending_p = 1;
lwp->status_pending = wstat;
}
initial_thread->last_resume_kind = resume_continue;
async_file_mark ();
gdb_assert (proc->tdesc != NULL);
}
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
return 0;
}
static int
last_thread_of_process_p (int pid)
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
{
bool seen_one = false;
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
thread_info *thread = find_thread (pid, [&] (thread_info *thr_arg)
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
{
if (!seen_one)
{
/* This is the first thread of this process we see. */
seen_one = true;
return false;
}
else
{
/* This is the second thread of this process we see. */
return true;
}
});
return thread == NULL;
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
}
/* Kill LWP. */
static void
linux_kill_one_lwp (struct lwp_info *lwp)
{
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
struct thread_info *thr = get_lwp_thread (lwp);
int pid = lwpid_of (thr);
/* PTRACE_KILL is unreliable. After stepping into a signal handler,
there is no signal context, and ptrace(PTRACE_KILL) (or
ptrace(PTRACE_CONT, SIGKILL), pretty much the same) acts like
ptrace(CONT, pid, 0,0) and just resumes the tracee. A better
alternative is to kill with SIGKILL. We only need one SIGKILL
per process, not one for each thread. But since we still support
Remove support for LinuxThreads and vendor 2.4 kernels w/ backported NPTL Since we now rely on PTRACE_EVENT_CLONE being available (added in Linux 2.5.46), we're relying on NPTL. This commit removes the support for older LinuxThreads, as well as the workarounds for vendor 2.4 kernels with NPTL backported. - Rely on tkill being available. - Assume gdb doesn't get cancel signals. - Remove code that checks the LinuxThreads restart and cancel signals in the inferior. - Assume that __WALL is available. - Assume that non-leader threads report WIFEXITED. - Thus, no longer need to send signal 0 to check whether threads are still alive. - Update comments throughout. Tested on x86_64 Fedora 20, native and gdbserver. gdb/ChangeLog: * configure.ac: Remove tkill checks. * configure, config.in: Regenerate. * linux-nat.c: Remove HAVE_TKILL_SYSCALL check. Update top level comments. (linux_nat_post_attach_wait): Remove 'cloned' parameter. Use __WALL. (attach_proc_task_lwp_callback): Don't set the cloned flag. (linux_nat_attach): Adjust. (kill_lwp): Remove HAVE_TKILL_SYSCALL check. No longer fall back to 'kill'. (linux_handle_extended_wait): Use __WALL. Don't set the cloned flag. (wait_lwp): Use __WALL. Update comments. (running_callback, stop_and_resume_callback): Delete. (linux_nat_filter_event): Don't stop and resume all lwps. Don't check if the event LWP has previously exited. (check_zombie_leaders): Update comments. (linux_nat_wait_1): Use __WALL. (kill_wait_callback): Don't handle clone processes separately. Use __WALL instead. (linux_thread_alive): Delete. (linux_nat_thread_alive): Return true as long as the LWP is in the LWP list. (linux_nat_update_thread_list): Assume the kernel supports PTRACE_EVENT_CLONE. (get_signo): Delete. (lin_thread_get_thread_signals): Remove LinuxThreads references. No longer check __pthread_sig_restart / __pthread_sig_cancel in the inferior. * linux-nat.h (struct lwp_info) <cloned>: Delete field. * linux-thread-db.c: Update comments. (_initialize_thread_db): Remove LinuxThreads references. * nat/linux-waitpid.c (my_waitpid): No longer emulate __WALL. Pass down flags unmodified. * linux-waitpid.h (my_waitpid): Update documentation. gdb/gdbserver/ChangeLog: * linux-low.c (linux_kill_one_lwp): Remove references to LinuxThreads. (kill_lwp): Remove HAVE_TKILL_SYSCALL check. No longer fall back to 'kill'. (linux_init_signals): Delete. (initialize_low): Adjust. * thread-db.c (thread_db_init): Remove LinuxThreads reference.
2015-12-17 15:20:51 +01:00
support debugging programs using raw clone without CLONE_THREAD,
we send one for each thread. For years, we used PTRACE_KILL
only, so we're being a bit paranoid about some old kernels where
PTRACE_KILL might work better (dubious if there are any such, but
that's why it's paranoia), so we try SIGKILL first, PTRACE_KILL
second, and so we're fine everywhere. */
errno = 0;
kill_lwp (pid, SIGKILL);
if (debug_threads)
{
int save_errno = errno;
debug_printf ("LKL: kill_lwp (SIGKILL) %s, 0, 0 (%s)\n",
target_pid_to_str (ptid_of (thr)),
save_errno ? safe_strerror (save_errno) : "OK");
}
errno = 0;
ptrace (PTRACE_KILL, pid, (PTRACE_TYPE_ARG3) 0, (PTRACE_TYPE_ARG4) 0);
if (debug_threads)
{
int save_errno = errno;
debug_printf ("LKL: PTRACE_KILL %s, 0, 0 (%s)\n",
target_pid_to_str (ptid_of (thr)),
save_errno ? safe_strerror (save_errno) : "OK");
}
}
GDBserver crashes when killing a multi-thread process Here's an example, with the new test: gdbserver :9999 gdb.threads/kill gdb gdb.threads/kill (gdb) b 52 Breakpoint 1 at 0x4007f4: file kill.c, line 52. Continuing. Breakpoint 1, main () at kill.c:52 52 return 0; /* set break here */ (gdb) k Kill the program being debugged? (y or n) y gdbserver :9999 gdb.threads/kill Process gdb.base/watch_thread_num created; pid = 9719 Listening on port 1234 Remote debugging from host 127.0.0.1 Killing all inferiors Segmentation fault (core dumped) Backtrace: (gdb) bt #0 0x00000000004068a0 in find_inferior (list=0x66b060 <all_threads>, func=0x427637 <kill_one_lwp_callback>, arg=0x7fffffffd3fc) at src/gdb/gdbserver/inferiors.c:199 #1 0x00000000004277b6 in linux_kill (pid=15708) at src/gdb/gdbserver/linux-low.c:966 #2 0x000000000041354d in kill_inferior (pid=15708) at src/gdb/gdbserver/target.c:163 #3 0x00000000004107e9 in kill_inferior_callback (entry=0x6704f0) at src/gdb/gdbserver/server.c:2934 #4 0x0000000000406522 in for_each_inferior (list=0x66b050 <all_processes>, action=0x4107a6 <kill_inferior_callback>) at src/gdb/gdbserver/inferiors.c:57 #5 0x0000000000412377 in process_serial_event () at src/gdb/gdbserver/server.c:3767 #6 0x000000000041267c in handle_serial_event (err=0, client_data=0x0) at src/gdb/gdbserver/server.c:3880 #7 0x00000000004189ff in handle_file_event (event_file_desc=4) at src/gdb/gdbserver/event-loop.c:434 #8 0x00000000004181c6 in process_event () at src/gdb/gdbserver/event-loop.c:189 #9 0x0000000000418f45 in start_event_loop () at src/gdb/gdbserver/event-loop.c:552 #10 0x0000000000411272 in main (argc=3, argv=0x7fffffffd8d8) at src/gdb/gdbserver/server.c:3283 The problem is that linux_wait_for_event deletes lwps that have exited (even those not passed in as lwps of interest), while the lwp/thread list is being walked on with find_inferior. find_inferior can handle the current iterated inferior being deleted, but not others. When killing lwps, we don't really care about any of the pending status handling of linux_wait_for_event. We can just waitpid the lwps directly, which is also what GDB does (see linux-nat.c:kill_wait_callback). This way the lwps are not deleted while we're walking the list. They'll be deleted by linux_mourn afterwards. This crash triggers several times when running the testsuite against GDBserver with the native-gdbserver board (target remote), but as GDB can't distinguish between GDBserver crashing and "kill" being sucessful, as in both cases the connection is closed (the 'k' packet doesn't require a reply), and the inferior is gone, that results in no FAIL. The patch adds a generic test that catches the issue with extended-remote mode (and works fine with native testing too). Here's how it fails with the native-extended-gdbserver board without the fix: (gdb) info threads Id Target Id Frame 6 Thread 15367.15374 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 5 Thread 15367.15373 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 4 Thread 15367.15372 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 3 Thread 15367.15371 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 2 Thread 15367.15370 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 * 1 Thread 15367.15367 main () at .../gdb.threads/kill.c:52 (gdb) kill Kill the program being debugged? (y or n) y Remote connection closed ^^^^^^^^^^^^^^^^^^^^^^^^ (gdb) FAIL: gdb.threads/kill.exp: kill Extended remote should remain connected after the kill. gdb/gdbserver/ 2014-07-11 Pedro Alves <palves@redhat.com> * linux-low.c (kill_wait_lwp): New function, based on kill_one_lwp_callback, but use my_waitpid directly. (kill_one_lwp_callback, linux_kill): Use it. gdb/testsuite/ 2014-07-11 Pedro Alves <palves@redhat.com> * gdb.threads/kill.c: New file. * gdb.threads/kill.exp: New file.
2014-07-11 12:07:13 +02:00
/* Kill LWP and wait for it to die. */
static void
kill_wait_lwp (struct lwp_info *lwp)
{
struct thread_info *thr = get_lwp_thread (lwp);
Remove ptid_get_pid This removes ptid_get_pid in favor of calling the ptid_t::pid method. gdb/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * common/ptid.c (ptid_get_pid): Remove. * common/ptid.h (ptid_get_pid): Don't declare. * aarch64-linux-nat.c: Update. * ada-lang.c: Update. * aix-thread.c: Update. * alpha-bsd-nat.c: Update. * amd64-fbsd-nat.c: Update. * amd64-linux-nat.c: Update. * arm-linux-nat.c: Update. * arm-nbsd-nat.c: Update. * auxv.c: Update. * break-catch-syscall.c: Update. * breakpoint.c: Update. * bsd-uthread.c: Update. * corelow.c: Update. * ctf.c: Update. * darwin-nat.c: Update. * fbsd-nat.c: Update. * fbsd-tdep.c: Update. * gcore.c: Update. * gnu-nat.c: Update. * hppa-nbsd-nat.c: Update. * hppa-obsd-nat.c: Update. * i386-fbsd-nat.c: Update. * ia64-linux-nat.c: Update. * inf-ptrace.c: Update. * infcmd.c: Update. * inferior.c: Update. * inferior.h: Update. * inflow.c: Update. * infrun.c: Update. * linux-fork.c: Update. * linux-nat.c: Update. * linux-tdep.c: Update. * linux-thread-db.c: Update. * m68k-bsd-nat.c: Update. * mi/mi-interp.c: Update. * mi/mi-main.c: Update. * mips-linux-nat.c: Update. * mips-nbsd-nat.c: Update. * mips64-obsd-nat.c: Update. * nat/aarch64-linux-hw-point.c: Update. * nat/aarch64-linux.c: Update. * nat/linux-btrace.c: Update. * nat/linux-osdata.c: Update. * nat/linux-procfs.c: Update. * nat/x86-linux-dregs.c: Update. * nto-procfs.c: Update. * obsd-nat.c: Update. * ppc-linux-nat.c: Update. * ppc-nbsd-nat.c: Update. * ppc-obsd-nat.c: Update. * proc-service.c: Update. * procfs.c: Update. * python/py-inferior.c: Update. * python/py-infthread.c: Update. * ravenscar-thread.c: Update. * record.c: Update. * remote-sim.c: Update. * remote.c: Update. * rs6000-nat.c: Update. * s390-linux-nat.c: Update. * sh-nbsd-nat.c: Update. * sol-thread.c: Update. * sparc-nat.c: Update. * sparc64-tdep.c: Update. * spu-linux-nat.c: Update. * spu-tdep.c: Update. * target-debug.h: Update. * target.c: Update. * thread.c: Update. * tid-parse.c: Update. * tracefile-tfile.c: Update. * vax-bsd-nat.c: Update. * windows-nat.c: Update. * x86-linux-nat.c: Update. * x86-nat.c: Update. gdb/gdbserver/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * linux-low.c: Update. * linux-mips-low.c: Update. * lynx-low.c: Update. * mem-break.c: Update. * nto-low.c: Update. * remote-utils.c: Update. * server.c: Update. * spu-low.c: Update. * target.c: Update. * tracepoint.c: Update.
2018-06-11 20:05:27 +02:00
int pid = ptid_of (thr).pid ();
Remove ptid_get_lwp This removes ptid_get_lwp in favor of calling the ptid_t::lwp method. gdb/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * common/ptid.c (ptid_get_lwp): Remove. * common/ptid.h (ptid_get_lwp): Don't declare. * aarch64-linux-nat.c: Update. * ada-tasks.c: Update. * aix-thread.c: Update. * amd64-linux-nat.c: Update. * arm-linux-nat.c: Update. * corelow.c: Update. * fbsd-nat.c: Update. * fbsd-tdep.c: Update. * gnu-nat.c: Update. * i386-cygwin-tdep.c: Update. * i386-gnu-nat.c: Update. * i386-linux-nat.c: Update. * ia64-linux-nat.c: Update. * inf-ptrace.c: Update. * infrun.c: Update. * linux-fork.c: Update. * linux-nat.c: Update. * linux-tdep.c: Update. * linux-thread-db.c: Update. * mips-linux-nat.c: Update. * nat/aarch64-linux-hw-point.c: Update. * nat/aarch64-linux.c: Update. * nat/linux-btrace.c: Update. * nat/linux-osdata.c: Update. * nat/linux-procfs.c: Update. * nat/x86-linux-dregs.c: Update. * obsd-nat.c: Update. * ppc-fbsd-nat.c: Update. * ppc-linux-nat.c: Update. * procfs.c: Update. * python/py-infthread.c: Update. * ravenscar-thread.c: Update. * remote.c: Update. * s390-linux-nat.c: Update. * sol-thread.c: Update. * sol2-tdep.c: Update. * spu-linux-nat.c: Update. * x86-linux-nat.c: Update. * xtensa-linux-nat.c: Update. gdb/gdbserver/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * linux-low.c: Update. * linux-mips-low.c: Update. * lynx-low.c: Update. * nto-low.c: Update. * remote-utils.c: Update. * server.c: Update. * spu-low.c: Update. * target.c: Update. * thread-db.c: Update.
2018-06-11 20:10:09 +02:00
int lwpid = ptid_of (thr).lwp ();
GDBserver crashes when killing a multi-thread process Here's an example, with the new test: gdbserver :9999 gdb.threads/kill gdb gdb.threads/kill (gdb) b 52 Breakpoint 1 at 0x4007f4: file kill.c, line 52. Continuing. Breakpoint 1, main () at kill.c:52 52 return 0; /* set break here */ (gdb) k Kill the program being debugged? (y or n) y gdbserver :9999 gdb.threads/kill Process gdb.base/watch_thread_num created; pid = 9719 Listening on port 1234 Remote debugging from host 127.0.0.1 Killing all inferiors Segmentation fault (core dumped) Backtrace: (gdb) bt #0 0x00000000004068a0 in find_inferior (list=0x66b060 <all_threads>, func=0x427637 <kill_one_lwp_callback>, arg=0x7fffffffd3fc) at src/gdb/gdbserver/inferiors.c:199 #1 0x00000000004277b6 in linux_kill (pid=15708) at src/gdb/gdbserver/linux-low.c:966 #2 0x000000000041354d in kill_inferior (pid=15708) at src/gdb/gdbserver/target.c:163 #3 0x00000000004107e9 in kill_inferior_callback (entry=0x6704f0) at src/gdb/gdbserver/server.c:2934 #4 0x0000000000406522 in for_each_inferior (list=0x66b050 <all_processes>, action=0x4107a6 <kill_inferior_callback>) at src/gdb/gdbserver/inferiors.c:57 #5 0x0000000000412377 in process_serial_event () at src/gdb/gdbserver/server.c:3767 #6 0x000000000041267c in handle_serial_event (err=0, client_data=0x0) at src/gdb/gdbserver/server.c:3880 #7 0x00000000004189ff in handle_file_event (event_file_desc=4) at src/gdb/gdbserver/event-loop.c:434 #8 0x00000000004181c6 in process_event () at src/gdb/gdbserver/event-loop.c:189 #9 0x0000000000418f45 in start_event_loop () at src/gdb/gdbserver/event-loop.c:552 #10 0x0000000000411272 in main (argc=3, argv=0x7fffffffd8d8) at src/gdb/gdbserver/server.c:3283 The problem is that linux_wait_for_event deletes lwps that have exited (even those not passed in as lwps of interest), while the lwp/thread list is being walked on with find_inferior. find_inferior can handle the current iterated inferior being deleted, but not others. When killing lwps, we don't really care about any of the pending status handling of linux_wait_for_event. We can just waitpid the lwps directly, which is also what GDB does (see linux-nat.c:kill_wait_callback). This way the lwps are not deleted while we're walking the list. They'll be deleted by linux_mourn afterwards. This crash triggers several times when running the testsuite against GDBserver with the native-gdbserver board (target remote), but as GDB can't distinguish between GDBserver crashing and "kill" being sucessful, as in both cases the connection is closed (the 'k' packet doesn't require a reply), and the inferior is gone, that results in no FAIL. The patch adds a generic test that catches the issue with extended-remote mode (and works fine with native testing too). Here's how it fails with the native-extended-gdbserver board without the fix: (gdb) info threads Id Target Id Frame 6 Thread 15367.15374 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 5 Thread 15367.15373 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 4 Thread 15367.15372 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 3 Thread 15367.15371 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 2 Thread 15367.15370 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 * 1 Thread 15367.15367 main () at .../gdb.threads/kill.c:52 (gdb) kill Kill the program being debugged? (y or n) y Remote connection closed ^^^^^^^^^^^^^^^^^^^^^^^^ (gdb) FAIL: gdb.threads/kill.exp: kill Extended remote should remain connected after the kill. gdb/gdbserver/ 2014-07-11 Pedro Alves <palves@redhat.com> * linux-low.c (kill_wait_lwp): New function, based on kill_one_lwp_callback, but use my_waitpid directly. (kill_one_lwp_callback, linux_kill): Use it. gdb/testsuite/ 2014-07-11 Pedro Alves <palves@redhat.com> * gdb.threads/kill.c: New file. * gdb.threads/kill.exp: New file.
2014-07-11 12:07:13 +02:00
int wstat;
int res;
if (debug_threads)
debug_printf ("kwl: killing lwp %d, for pid: %d\n", lwpid, pid);
do
{
linux_kill_one_lwp (lwp);
/* Make sure it died. Notes:
- The loop is most likely unnecessary.
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
- We don't use wait_for_event as that could delete lwps
GDBserver crashes when killing a multi-thread process Here's an example, with the new test: gdbserver :9999 gdb.threads/kill gdb gdb.threads/kill (gdb) b 52 Breakpoint 1 at 0x4007f4: file kill.c, line 52. Continuing. Breakpoint 1, main () at kill.c:52 52 return 0; /* set break here */ (gdb) k Kill the program being debugged? (y or n) y gdbserver :9999 gdb.threads/kill Process gdb.base/watch_thread_num created; pid = 9719 Listening on port 1234 Remote debugging from host 127.0.0.1 Killing all inferiors Segmentation fault (core dumped) Backtrace: (gdb) bt #0 0x00000000004068a0 in find_inferior (list=0x66b060 <all_threads>, func=0x427637 <kill_one_lwp_callback>, arg=0x7fffffffd3fc) at src/gdb/gdbserver/inferiors.c:199 #1 0x00000000004277b6 in linux_kill (pid=15708) at src/gdb/gdbserver/linux-low.c:966 #2 0x000000000041354d in kill_inferior (pid=15708) at src/gdb/gdbserver/target.c:163 #3 0x00000000004107e9 in kill_inferior_callback (entry=0x6704f0) at src/gdb/gdbserver/server.c:2934 #4 0x0000000000406522 in for_each_inferior (list=0x66b050 <all_processes>, action=0x4107a6 <kill_inferior_callback>) at src/gdb/gdbserver/inferiors.c:57 #5 0x0000000000412377 in process_serial_event () at src/gdb/gdbserver/server.c:3767 #6 0x000000000041267c in handle_serial_event (err=0, client_data=0x0) at src/gdb/gdbserver/server.c:3880 #7 0x00000000004189ff in handle_file_event (event_file_desc=4) at src/gdb/gdbserver/event-loop.c:434 #8 0x00000000004181c6 in process_event () at src/gdb/gdbserver/event-loop.c:189 #9 0x0000000000418f45 in start_event_loop () at src/gdb/gdbserver/event-loop.c:552 #10 0x0000000000411272 in main (argc=3, argv=0x7fffffffd8d8) at src/gdb/gdbserver/server.c:3283 The problem is that linux_wait_for_event deletes lwps that have exited (even those not passed in as lwps of interest), while the lwp/thread list is being walked on with find_inferior. find_inferior can handle the current iterated inferior being deleted, but not others. When killing lwps, we don't really care about any of the pending status handling of linux_wait_for_event. We can just waitpid the lwps directly, which is also what GDB does (see linux-nat.c:kill_wait_callback). This way the lwps are not deleted while we're walking the list. They'll be deleted by linux_mourn afterwards. This crash triggers several times when running the testsuite against GDBserver with the native-gdbserver board (target remote), but as GDB can't distinguish between GDBserver crashing and "kill" being sucessful, as in both cases the connection is closed (the 'k' packet doesn't require a reply), and the inferior is gone, that results in no FAIL. The patch adds a generic test that catches the issue with extended-remote mode (and works fine with native testing too). Here's how it fails with the native-extended-gdbserver board without the fix: (gdb) info threads Id Target Id Frame 6 Thread 15367.15374 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 5 Thread 15367.15373 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 4 Thread 15367.15372 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 3 Thread 15367.15371 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 2 Thread 15367.15370 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 * 1 Thread 15367.15367 main () at .../gdb.threads/kill.c:52 (gdb) kill Kill the program being debugged? (y or n) y Remote connection closed ^^^^^^^^^^^^^^^^^^^^^^^^ (gdb) FAIL: gdb.threads/kill.exp: kill Extended remote should remain connected after the kill. gdb/gdbserver/ 2014-07-11 Pedro Alves <palves@redhat.com> * linux-low.c (kill_wait_lwp): New function, based on kill_one_lwp_callback, but use my_waitpid directly. (kill_one_lwp_callback, linux_kill): Use it. gdb/testsuite/ 2014-07-11 Pedro Alves <palves@redhat.com> * gdb.threads/kill.c: New file. * gdb.threads/kill.exp: New file.
2014-07-11 12:07:13 +02:00
while we're iterating over them. We're not interested in
any pending status at this point, only in making sure all
wait status on the kernel side are collected until the
process is reaped.
- We don't use __WALL here as the __WALL emulation relies on
SIGCHLD, and killing a stopped process doesn't generate
one, nor an exit status.
*/
res = my_waitpid (lwpid, &wstat, 0);
if (res == -1 && errno == ECHILD)
res = my_waitpid (lwpid, &wstat, __WCLONE);
} while (res > 0 && WIFSTOPPED (wstat));
/* Even if it was stopped, the child may have already disappeared.
E.g., if it was killed by SIGKILL. */
if (res < 0 && errno != ECHILD)
perror_with_name ("kill_wait_lwp");
GDBserver crashes when killing a multi-thread process Here's an example, with the new test: gdbserver :9999 gdb.threads/kill gdb gdb.threads/kill (gdb) b 52 Breakpoint 1 at 0x4007f4: file kill.c, line 52. Continuing. Breakpoint 1, main () at kill.c:52 52 return 0; /* set break here */ (gdb) k Kill the program being debugged? (y or n) y gdbserver :9999 gdb.threads/kill Process gdb.base/watch_thread_num created; pid = 9719 Listening on port 1234 Remote debugging from host 127.0.0.1 Killing all inferiors Segmentation fault (core dumped) Backtrace: (gdb) bt #0 0x00000000004068a0 in find_inferior (list=0x66b060 <all_threads>, func=0x427637 <kill_one_lwp_callback>, arg=0x7fffffffd3fc) at src/gdb/gdbserver/inferiors.c:199 #1 0x00000000004277b6 in linux_kill (pid=15708) at src/gdb/gdbserver/linux-low.c:966 #2 0x000000000041354d in kill_inferior (pid=15708) at src/gdb/gdbserver/target.c:163 #3 0x00000000004107e9 in kill_inferior_callback (entry=0x6704f0) at src/gdb/gdbserver/server.c:2934 #4 0x0000000000406522 in for_each_inferior (list=0x66b050 <all_processes>, action=0x4107a6 <kill_inferior_callback>) at src/gdb/gdbserver/inferiors.c:57 #5 0x0000000000412377 in process_serial_event () at src/gdb/gdbserver/server.c:3767 #6 0x000000000041267c in handle_serial_event (err=0, client_data=0x0) at src/gdb/gdbserver/server.c:3880 #7 0x00000000004189ff in handle_file_event (event_file_desc=4) at src/gdb/gdbserver/event-loop.c:434 #8 0x00000000004181c6 in process_event () at src/gdb/gdbserver/event-loop.c:189 #9 0x0000000000418f45 in start_event_loop () at src/gdb/gdbserver/event-loop.c:552 #10 0x0000000000411272 in main (argc=3, argv=0x7fffffffd8d8) at src/gdb/gdbserver/server.c:3283 The problem is that linux_wait_for_event deletes lwps that have exited (even those not passed in as lwps of interest), while the lwp/thread list is being walked on with find_inferior. find_inferior can handle the current iterated inferior being deleted, but not others. When killing lwps, we don't really care about any of the pending status handling of linux_wait_for_event. We can just waitpid the lwps directly, which is also what GDB does (see linux-nat.c:kill_wait_callback). This way the lwps are not deleted while we're walking the list. They'll be deleted by linux_mourn afterwards. This crash triggers several times when running the testsuite against GDBserver with the native-gdbserver board (target remote), but as GDB can't distinguish between GDBserver crashing and "kill" being sucessful, as in both cases the connection is closed (the 'k' packet doesn't require a reply), and the inferior is gone, that results in no FAIL. The patch adds a generic test that catches the issue with extended-remote mode (and works fine with native testing too). Here's how it fails with the native-extended-gdbserver board without the fix: (gdb) info threads Id Target Id Frame 6 Thread 15367.15374 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 5 Thread 15367.15373 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 4 Thread 15367.15372 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 3 Thread 15367.15371 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 2 Thread 15367.15370 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 * 1 Thread 15367.15367 main () at .../gdb.threads/kill.c:52 (gdb) kill Kill the program being debugged? (y or n) y Remote connection closed ^^^^^^^^^^^^^^^^^^^^^^^^ (gdb) FAIL: gdb.threads/kill.exp: kill Extended remote should remain connected after the kill. gdb/gdbserver/ 2014-07-11 Pedro Alves <palves@redhat.com> * linux-low.c (kill_wait_lwp): New function, based on kill_one_lwp_callback, but use my_waitpid directly. (kill_one_lwp_callback, linux_kill): Use it. gdb/testsuite/ 2014-07-11 Pedro Alves <palves@redhat.com> * gdb.threads/kill.c: New file. * gdb.threads/kill.exp: New file.
2014-07-11 12:07:13 +02:00
}
/* Callback for `for_each_thread'. Kills an lwp of a given process,
except the leader. */
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
static void
kill_one_lwp_callback (thread_info *thread, int pid)
{
Rename "process" to "lwp" throughout. * linux-low.c (all_processes): Rename to... (all_lwps): ... this. (inferior_pid, handle_extended_wait, get_stop_pc): Adjust. (add_process): Rename to ... (add_lwp): ... this. Adjust. (linux_create_inferior): Adjust. (linux_attach_lwp): Adjust. (linux_attach): Adjust. (linux_kill_one_process): Rename to ... (linux_kill_one_lwp): ... this. Adjust. (linux_kill): Adjust. (linux_detach_one_process): Rename to ... (linux_detach_one_lwp): ... this. Adjust. (linux_detach): Adjust. (check_removed_breakpoint): Adjust. (status_pending_p): Adjust. (linux_wait_for_process): Rename to ... (linux_wait_for_lwp): ... this. Adjust. (linux_wait_for_event): Adjust. (send_sigstop): Adjust. (wait_for_sigstop): Adjust. (stop_all_processes): Rename to ... (stop_all_lwps): ... this. (linux_resume_one_process): Rename to ... (linux_resume_one_lwp): ... this. Adjust. (linux_set_resume_request, linux_continue_one_thread) (linux_queue_one_thread, resume_status_pending_p) (usr_store_inferior_registers, regsets_store_inferior_registers) (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Adjust. * linux-low.h (get_process): Rename to ... (get_lwp): ... this. Adjust. (get_thread_process): Rename to ... (get_thread_lwp): ... this. Adjust. (get_process_thread): Rename to ... (get_lwp_thread): ... this. Adjust. (struct process_info): Rename to ... (struct lwp_info): ... this. (all_processes): Rename to ... (all_lwps): ... this. * proc-service.c (ps_lgetregs): Adjust. * thread-db.c (thread_db_create_event, find_one_thread) (maybe_attach_thread, thread_db_get_tls_address): Adjust.
2009-03-17 21:25:35 +01:00
struct lwp_info *lwp = get_thread_lwp (thread);
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
/* We avoid killing the first thread here, because of a Linux kernel (at
least 2.6.0-test7 through 2.6.8-rc4) bug; if we kill the parent before
the children get a chance to be reaped, it will remain a zombie
forever. */
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
if (lwpid_of (thread) == pid)
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("lkop: is last of process %s\n",
gdbserver: use std::list for all_threads Remove the usage of inferior_list for the all_threads list in gdbserver. The entry field in thread_info is removed, and replaced by a simple ptid field. I added some functions to iterate (for_each_thread) and find threads (find_thread). However, changing all the users of find_inferior & co to use these new functions would have made the patch way too big. So I opted instead to make find_inferior & co some shims, so that the existing code only needs to be updated minimally. We can then update the existing code to use the new functions incrementally (I've started to do the work, but I'll post it afterwards, see [1] if you want a peek). This patch has been built-tested on all relevant platforms, except lynx. I also regtested using the native-gdbserver and native-extended-gdbserver boards on x86. [1] https://github.com/simark/binutils-gdb/commits/kill-inferior-list-entry gdb/gdbserver/ChangeLog: * inferiors.h: (struct inferior_list): Remove. (struct inferior_list_entry); Remove. (add_inferior_to_list, clear_inferior_list, one_inferior_p, A_I_NEXT, ALL_INFERIORS_TYPE, ALL_INFERIORS, remove_inferior, get_first_inferior): Remove. (for_each_inferior, for_each_inferior_with_data, find_inferior, find_inferior_id, find_inferior_in_random): Change signature. * inferiors.c (all_threads): Change type to std::list<thread_info *>. (get_thread): Remove macro. (find_inferior, find_inferior_id): Change signature, implement using find_thread. (find_inferior_in_random): Change signature, implement using find_thread_in_random. (for_each_inferior, for_each_inferior_with_data): Change signature, implement using for_each_thread. (add_inferior_to_list, remove_inferior): Remove. (add_thread, get_first_thread, thread_of_pid, find_any_thread_of_pid, free_one_thread, remove_thread): Update. (get_first_inferior, one_inferior_p, clear_inferior_list): Remove. (clear_inferiors, get_thread_process): Update. * gdbthread.h: Include <list>. (struct thread_info) <entry>: Remove field. <id>: New field. (all_threads): Change type to std::list<thread_info *>. (get_first_inferior): Add doc. (find_thread, for_each_thread, find_thread_in_random): New functions. (current_ptid, pid_of, ptid_of, lwpid_of): Update. * linux-arm-low.c (update_registers_callback): Update. * linux-low.c (second_thread_of_pid_p): Update. (kill_one_lwp_callback, linux_detach_lwp_callback, delete_lwp_callback, status_pending_p_callback, same_lwp, find_lwp_pid, num_lwps, iterate_over_lwps_filter, iterate_over_lwps, not_stopped_callback, resume_stopped_resumed_lwps, count_events_callback, select_singlestep_lwp_callback, select_event_lwp_callback, unsuspend_one_lwp, linux_wait_1, send_sigstop_callback, suspend_and_send_sigstop_callback, wait_for_sigstop, stuck_in_jump_pad_callback, move_out_of_jump_pad_callback, lwp_running, linux_set_resume_request, resume_status_pending_p, need_step_over_p, start_step_over, linux_resume_one_thread, proceed_one_lwp, unsuspend_and_proceed_one_lwp, reset_lwp_ptrace_options_callback): Update. * linux-mips-low.c (update_watch_registers_callback): Update. * regcache.c (regcache_invalidate_one, regcache_invalidate): Update. (free_register_cache_thread_one): Remove. (regcache_release): Update. * server.c (handle_btrace_enable_bts, handle_btrace_enable_pt, handle_qxfer_threads_worker): Update. (handle_query): Update, use list iterator. (visit_actioned_threads, handle_pending_status, queue_stop_reply_callback, gdb_wants_all_threads_stopped, clear_pending_status_callback, set_pending_status_callback, find_status_pending_thread_callback, handle_status, process_serial_event): Update. * target.c (thread_search_callback): Update. * thread-db.c (thread_db_get_tls_address): Update. * tracepoint.c (tracepoint_finished_step, tracepoint_was_hit): Update. * win32-i386-low.c (update_debug_registers_callback): Update. * win32-low.c (delete_thread_info, child_delete_thread, continue_one_thread, suspend_one_thread, get_child_debug_event): Adjust.
2017-10-14 15:11:12 +02:00
target_pid_to_str (thread->id));
return;
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
}
GDBserver crashes when killing a multi-thread process Here's an example, with the new test: gdbserver :9999 gdb.threads/kill gdb gdb.threads/kill (gdb) b 52 Breakpoint 1 at 0x4007f4: file kill.c, line 52. Continuing. Breakpoint 1, main () at kill.c:52 52 return 0; /* set break here */ (gdb) k Kill the program being debugged? (y or n) y gdbserver :9999 gdb.threads/kill Process gdb.base/watch_thread_num created; pid = 9719 Listening on port 1234 Remote debugging from host 127.0.0.1 Killing all inferiors Segmentation fault (core dumped) Backtrace: (gdb) bt #0 0x00000000004068a0 in find_inferior (list=0x66b060 <all_threads>, func=0x427637 <kill_one_lwp_callback>, arg=0x7fffffffd3fc) at src/gdb/gdbserver/inferiors.c:199 #1 0x00000000004277b6 in linux_kill (pid=15708) at src/gdb/gdbserver/linux-low.c:966 #2 0x000000000041354d in kill_inferior (pid=15708) at src/gdb/gdbserver/target.c:163 #3 0x00000000004107e9 in kill_inferior_callback (entry=0x6704f0) at src/gdb/gdbserver/server.c:2934 #4 0x0000000000406522 in for_each_inferior (list=0x66b050 <all_processes>, action=0x4107a6 <kill_inferior_callback>) at src/gdb/gdbserver/inferiors.c:57 #5 0x0000000000412377 in process_serial_event () at src/gdb/gdbserver/server.c:3767 #6 0x000000000041267c in handle_serial_event (err=0, client_data=0x0) at src/gdb/gdbserver/server.c:3880 #7 0x00000000004189ff in handle_file_event (event_file_desc=4) at src/gdb/gdbserver/event-loop.c:434 #8 0x00000000004181c6 in process_event () at src/gdb/gdbserver/event-loop.c:189 #9 0x0000000000418f45 in start_event_loop () at src/gdb/gdbserver/event-loop.c:552 #10 0x0000000000411272 in main (argc=3, argv=0x7fffffffd8d8) at src/gdb/gdbserver/server.c:3283 The problem is that linux_wait_for_event deletes lwps that have exited (even those not passed in as lwps of interest), while the lwp/thread list is being walked on with find_inferior. find_inferior can handle the current iterated inferior being deleted, but not others. When killing lwps, we don't really care about any of the pending status handling of linux_wait_for_event. We can just waitpid the lwps directly, which is also what GDB does (see linux-nat.c:kill_wait_callback). This way the lwps are not deleted while we're walking the list. They'll be deleted by linux_mourn afterwards. This crash triggers several times when running the testsuite against GDBserver with the native-gdbserver board (target remote), but as GDB can't distinguish between GDBserver crashing and "kill" being sucessful, as in both cases the connection is closed (the 'k' packet doesn't require a reply), and the inferior is gone, that results in no FAIL. The patch adds a generic test that catches the issue with extended-remote mode (and works fine with native testing too). Here's how it fails with the native-extended-gdbserver board without the fix: (gdb) info threads Id Target Id Frame 6 Thread 15367.15374 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 5 Thread 15367.15373 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 4 Thread 15367.15372 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 3 Thread 15367.15371 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 2 Thread 15367.15370 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 * 1 Thread 15367.15367 main () at .../gdb.threads/kill.c:52 (gdb) kill Kill the program being debugged? (y or n) y Remote connection closed ^^^^^^^^^^^^^^^^^^^^^^^^ (gdb) FAIL: gdb.threads/kill.exp: kill Extended remote should remain connected after the kill. gdb/gdbserver/ 2014-07-11 Pedro Alves <palves@redhat.com> * linux-low.c (kill_wait_lwp): New function, based on kill_one_lwp_callback, but use my_waitpid directly. (kill_one_lwp_callback, linux_kill): Use it. gdb/testsuite/ 2014-07-11 Pedro Alves <palves@redhat.com> * gdb.threads/kill.c: New file. * gdb.threads/kill.exp: New file.
2014-07-11 12:07:13 +02:00
kill_wait_lwp (lwp);
}
int
linux_process_target::kill (process_info *process)
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
{
int pid = process->pid;
/* If we're killing a running inferior, make sure it is stopped
first, as PTRACE_KILL will not work otherwise. */
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
stop_all_lwps (0, NULL);
for_each_thread (pid, [&] (thread_info *thread)
{
kill_one_lwp_callback (thread, pid);
});
Rename "process" to "lwp" throughout. * linux-low.c (all_processes): Rename to... (all_lwps): ... this. (inferior_pid, handle_extended_wait, get_stop_pc): Adjust. (add_process): Rename to ... (add_lwp): ... this. Adjust. (linux_create_inferior): Adjust. (linux_attach_lwp): Adjust. (linux_attach): Adjust. (linux_kill_one_process): Rename to ... (linux_kill_one_lwp): ... this. Adjust. (linux_kill): Adjust. (linux_detach_one_process): Rename to ... (linux_detach_one_lwp): ... this. Adjust. (linux_detach): Adjust. (check_removed_breakpoint): Adjust. (status_pending_p): Adjust. (linux_wait_for_process): Rename to ... (linux_wait_for_lwp): ... this. Adjust. (linux_wait_for_event): Adjust. (send_sigstop): Adjust. (wait_for_sigstop): Adjust. (stop_all_processes): Rename to ... (stop_all_lwps): ... this. (linux_resume_one_process): Rename to ... (linux_resume_one_lwp): ... this. Adjust. (linux_set_resume_request, linux_continue_one_thread) (linux_queue_one_thread, resume_status_pending_p) (usr_store_inferior_registers, regsets_store_inferior_registers) (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Adjust. * linux-low.h (get_process): Rename to ... (get_lwp): ... this. Adjust. (get_thread_process): Rename to ... (get_thread_lwp): ... this. Adjust. (get_process_thread): Rename to ... (get_lwp_thread): ... this. Adjust. (struct process_info): Rename to ... (struct lwp_info): ... this. (all_processes): Rename to ... (all_lwps): ... this. * proc-service.c (ps_lgetregs): Adjust. * thread-db.c (thread_db_create_event, find_one_thread) (maybe_attach_thread, thread_db_get_tls_address): Adjust.
2009-03-17 21:25:35 +01:00
/* See the comment in linux_kill_one_lwp. We did not kill the first
thread in the list, so do so now. */
lwp_info *lwp = find_lwp_pid (ptid_t (pid));
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
if (lwp == NULL)
{
if (debug_threads)
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
debug_printf ("lk_1: cannot find lwp for pid: %d\n",
pid);
}
else
GDBserver crashes when killing a multi-thread process Here's an example, with the new test: gdbserver :9999 gdb.threads/kill gdb gdb.threads/kill (gdb) b 52 Breakpoint 1 at 0x4007f4: file kill.c, line 52. Continuing. Breakpoint 1, main () at kill.c:52 52 return 0; /* set break here */ (gdb) k Kill the program being debugged? (y or n) y gdbserver :9999 gdb.threads/kill Process gdb.base/watch_thread_num created; pid = 9719 Listening on port 1234 Remote debugging from host 127.0.0.1 Killing all inferiors Segmentation fault (core dumped) Backtrace: (gdb) bt #0 0x00000000004068a0 in find_inferior (list=0x66b060 <all_threads>, func=0x427637 <kill_one_lwp_callback>, arg=0x7fffffffd3fc) at src/gdb/gdbserver/inferiors.c:199 #1 0x00000000004277b6 in linux_kill (pid=15708) at src/gdb/gdbserver/linux-low.c:966 #2 0x000000000041354d in kill_inferior (pid=15708) at src/gdb/gdbserver/target.c:163 #3 0x00000000004107e9 in kill_inferior_callback (entry=0x6704f0) at src/gdb/gdbserver/server.c:2934 #4 0x0000000000406522 in for_each_inferior (list=0x66b050 <all_processes>, action=0x4107a6 <kill_inferior_callback>) at src/gdb/gdbserver/inferiors.c:57 #5 0x0000000000412377 in process_serial_event () at src/gdb/gdbserver/server.c:3767 #6 0x000000000041267c in handle_serial_event (err=0, client_data=0x0) at src/gdb/gdbserver/server.c:3880 #7 0x00000000004189ff in handle_file_event (event_file_desc=4) at src/gdb/gdbserver/event-loop.c:434 #8 0x00000000004181c6 in process_event () at src/gdb/gdbserver/event-loop.c:189 #9 0x0000000000418f45 in start_event_loop () at src/gdb/gdbserver/event-loop.c:552 #10 0x0000000000411272 in main (argc=3, argv=0x7fffffffd8d8) at src/gdb/gdbserver/server.c:3283 The problem is that linux_wait_for_event deletes lwps that have exited (even those not passed in as lwps of interest), while the lwp/thread list is being walked on with find_inferior. find_inferior can handle the current iterated inferior being deleted, but not others. When killing lwps, we don't really care about any of the pending status handling of linux_wait_for_event. We can just waitpid the lwps directly, which is also what GDB does (see linux-nat.c:kill_wait_callback). This way the lwps are not deleted while we're walking the list. They'll be deleted by linux_mourn afterwards. This crash triggers several times when running the testsuite against GDBserver with the native-gdbserver board (target remote), but as GDB can't distinguish between GDBserver crashing and "kill" being sucessful, as in both cases the connection is closed (the 'k' packet doesn't require a reply), and the inferior is gone, that results in no FAIL. The patch adds a generic test that catches the issue with extended-remote mode (and works fine with native testing too). Here's how it fails with the native-extended-gdbserver board without the fix: (gdb) info threads Id Target Id Frame 6 Thread 15367.15374 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 5 Thread 15367.15373 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 4 Thread 15367.15372 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 3 Thread 15367.15371 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 2 Thread 15367.15370 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81 * 1 Thread 15367.15367 main () at .../gdb.threads/kill.c:52 (gdb) kill Kill the program being debugged? (y or n) y Remote connection closed ^^^^^^^^^^^^^^^^^^^^^^^^ (gdb) FAIL: gdb.threads/kill.exp: kill Extended remote should remain connected after the kill. gdb/gdbserver/ 2014-07-11 Pedro Alves <palves@redhat.com> * linux-low.c (kill_wait_lwp): New function, based on kill_one_lwp_callback, but use my_waitpid directly. (kill_one_lwp_callback, linux_kill): Use it. gdb/testsuite/ 2014-07-11 Pedro Alves <palves@redhat.com> * gdb.threads/kill.c: New file. * gdb.threads/kill.exp: New file.
2014-07-11 12:07:13 +02:00
kill_wait_lwp (lwp);
* linux-low.c (linux_attach_lwp): Do not _exit after errors. (linux_kill, linux_detach): Clean up the process list. * remote-utils.c (remote_open): Improve port number parsing. (putpkt_binary, input_interrupt): Only send interrupts if the target is running. * server.c (extended_protocol): Make static. (attached): Define earlier. (exit_requested, response_needed, program_argv): New variables. (target_running): New. (start_inferior): Clear attached here. (attach_inferior): Set attached here. (require_running): Define. (handle_query): Use require_running and target_running. Implement "monitor exit". (handle_v_attach, handle_v_run): New. (handle_v_requests): Use require_running. Handle vAttach and vRun. (gdbserver_usage): Update. (main): Redo argument parsing. Handle --debug and --multi. Handle --attach along with other options or after the port. Save program_argv. Support no initial program. Resynchronize communication with GDB after an error. Handle "monitor exit". Use require_running and target_running. Always allow the extended protocol. Do not error out for Hc0 or Hc-1. Do not automatically restart in extended mode. * README: Refer to the GDB manual. Update --attach usage. * remote.c (struct remote_state): Add cached_wait_status. (remote_exec_file): New variable. (PACKET_vAttach, PACKET_vRun): New constants. (extended_remote_restart): Do not query for status. (struct start_remote_args): New. (remote_start_remote): Take it as a second argument. Check whether the target is running. Issue an error for non-running non-extended targets. Cache the wait status. Set inferior_ptid here. (remote_open_1): Prompt to disconnect non-running targets. Make sure the target is marked running. Do not set inferior_ptid here. Update call to remote_start_remote. Do not call remote_check_symbols if the target is not running. (remote_detach_1): Rename from remote_detach. Take an EXTENDED argument. Handle a non-running target. (remote_detach): Use it. (extended_remote_detach): New. (remote_disconnect): Fix typo. Use remoute_mourn_1. (extended_remote_attach_1, extended_remote_attach) (extended_async_remote_attach): New. (remote_vcont_resume): Remove unused variable. (remote_wait, remote_async_wait): Use any cached wait status. (putpkt_binary, getpkt): Clear any cached wait status. (extended_remoute_mourn_1): New. (extended_remote_mourn): Use it. (extended_async_remote_mourn, extended_remote_run): New. (extended_remote_create_inferior_1): New. (extended_remote_create_inferior): Use it. (extended_remote_async_create_inferior): Likewise. (remote_xfer_partial): Skip for non-executing targets. (init_extended_remote_ops): Set to_detach and to_attach. (init_extended_async_remote_ops): Likewise. Use extended_async_remote_mourn. (_initialize_remote): Register vAttach, vRun, and set remote exec-file. * NEWS: Mention vAttach, vRun, and gdbserver extended-remote support. * gdb.server/ext-attach.c, gdb.server/ext-attach.exp, gdb.server/ext-run.exp: New files. * lib/gdbserver-support.exp (gdbserver_download): New. (gdbserver_start): New. Update gdbserver expected output. (gdbserver_spawn): Use them. (gdbserver_start_extended): New. * gdb.texinfo (Using the `gdbserver' Program): Add security warning. Rearrange into subsections and subsubsections. Document --multi and --debug. Correct --with-sysroot typo. Update --attach usage. Make load reference clearer. Document monitor exit. (Remote Configuration): Document set remote exec-file, attach-packet, and run-packet. (Packets): Document vAttach and vRun.
2008-01-30 01:51:50 +01:00
mourn (process);
/* Since we presently can only stop all lwps of all processes, we
need to unstop lwps of other processes. */
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
unstop_all_lwps (0, NULL);
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
return 0;
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
}
/* Get pending signal of THREAD, for detaching purposes. This is the
signal the thread last stopped for, which we need to deliver to the
thread when detaching, otherwise, it'd be suppressed/lost. */
static int
get_detach_signal (struct thread_info *thread)
{
client_state &cs = get_client_state ();
gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. gdb/gdbserver/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. include/gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 * gdb/signals.def: Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/arm/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/avr/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/common/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/cr16/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/d10v/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/erc32/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/m32c/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/ppc/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rl78/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rx/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout.
2012-05-24 18:51:47 +02:00
enum gdb_signal signo = GDB_SIGNAL_0;
int status;
struct lwp_info *lp = get_thread_lwp (thread);
if (lp->status_pending_p)
status = lp->status_pending;
else
{
/* If the thread had been suspended by gdbserver, and it stopped
cleanly, then it'll have stopped with SIGSTOP. But we don't
want to deliver that SIGSTOP. */
if (thread->last_status.kind != TARGET_WAITKIND_STOPPED
gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. gdb/gdbserver/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. include/gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 * gdb/signals.def: Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/arm/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/avr/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/common/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/cr16/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/d10v/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/erc32/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/m32c/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/ppc/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rl78/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rx/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout.
2012-05-24 18:51:47 +02:00
|| thread->last_status.value.sig == GDB_SIGNAL_0)
return 0;
/* Otherwise, we may need to deliver the signal we
intercepted. */
status = lp->last_status;
}
if (!WIFSTOPPED (status))
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("GPS: lwp %s hasn't stopped: no pending signal\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
target_pid_to_str (ptid_of (thread)));
return 0;
}
/* Extended wait statuses aren't real SIGTRAPs. */
if (WSTOPSIG (status) == SIGTRAP && linux_is_extended_waitstatus (status))
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("GPS: lwp %s had stopped with extended "
"status: no pending signal\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
target_pid_to_str (ptid_of (thread)));
return 0;
}
signo = gdb_signal_from_host (WSTOPSIG (status));
if (cs.program_signals_p && !cs.program_signals[signo])
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("GPS: lwp %s had signal %s, but it is in nopass state\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
target_pid_to_str (ptid_of (thread)),
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
gdb_signal_to_string (signo));
return 0;
}
else if (!cs.program_signals_p
/* If we have no way to know which signals GDB does not
want to have passed to the program, assume
SIGTRAP/SIGINT, which is GDB's default. */
gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. gdb/gdbserver/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. include/gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 * gdb/signals.def: Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/arm/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/avr/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/common/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/cr16/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/d10v/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/erc32/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/m32c/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/ppc/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rl78/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rx/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout.
2012-05-24 18:51:47 +02:00
&& (signo == GDB_SIGNAL_TRAP || signo == GDB_SIGNAL_INT))
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("GPS: lwp %s had signal %s, "
"but we don't know if we should pass it. "
"Default to not.\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
target_pid_to_str (ptid_of (thread)),
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
gdb_signal_to_string (signo));
return 0;
}
else
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("GPS: lwp %s has pending signal %s: delivering it.\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
target_pid_to_str (ptid_of (thread)),
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
gdb_signal_to_string (signo));
return WSTOPSIG (status);
}
}
gdbserver/linux-low: turn process/thread addition/deletion ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'new_process', 'delete_process', 'new_thread', 'delete_thread', and 'new_fork' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <add_linux_process> <add_lwp> <delete_lwp> <attach_lwp> <detach_one_lwp> <check_zombie_leaders> <filter_exit_event> <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. * linux-low.cc (delete_lwp): Turn into... (linux_process_target::delete_lwp): ...this. (linux_process_target::low_delete_thread): Define. (linux_add_process): Turn into... (linux_process_target::add_linux_process): ...this. (linux_process_target::low_new_process): Define. (linux_process_target::low_delete_process): Define. (linux_process_target::low_new_fork): Define. (add_lwp): Turn into... (linux_process_target::add_lwp): ...this. (linux_process_target::low_new_thread): Define. (linux_attach_lwp): Turn into... (linux_process_target::attach_lwp): ...this. (linux_detach_one_lwp): Turn into... (linux_process_target::detach_one_lwp): ...this. (linux_detach_lwp_callback): Remove and inline... (linux_process_target::detach): ...here. (check_zombie_leaders): Turn into... (linux_process_target::check_zombie_leaders): ...this. (filter_exit_event): Turn into... (linux_process_target::filter_exit_event): ...this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::create_inferior) (attach_proc_task_lwp_callback) (linux_process_target::attach) (linux_process_target::detach) (linux_process_target::mourn) * thread-db.cc (attach_thread) * linux-x86-low.cc (class x86_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (x86_linux_new_process): Turn into... (x86_target::low_new_process): ...this. (x86_linux_delete_process): Turn into... (x86_target::low_delete_process): ...this. (x86_target::low_new_thread): Define. (x86_target::low_delete_thread): Define. (x86_linux_new_fork): Turn into... (x86_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (aarch64_linux_new_process): Turn into... (aarch64_target::low_new_process): ...this. (aarch64_linux_delete_process): Turn into... (aarch64_target::low_delete_process): ...this. (aarch64_target::low_new_thread): Define. (aarch64_target::low_delete_thread): Define. (aarch64_linux_new_fork): Turn into... (aarch64_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (arm_new_process): Turn into... (arm_target::low_new_process): ...this. (arm_delete_process): Turn into... (arm_target::low_delete_process): ...this. (arm_new_thread): Turn into... (arm_target::low_new_thread): ...this. (arm_delete_thread): Turn into... (arm_target::low_delete_thread): ...this. (arm_new_fork): Turn into... (arm_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (mips_linux_new_process): Turn into... (mips_target::low_new_process): ...this. (mips_linux_delete_process): Turn into... (mips_target::low_delete_process): ...this. (mips_linux_new_thread): Turn into... (mips_target::low_new_thread): ...this. (mips_linux_delete_thread): Turn into... (mips_target::low_delete_thread): ...this. (mips_linux_new_fork): Turn into... (mips_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:28 +02:00
void
linux_process_target::detach_one_lwp (lwp_info *lwp)
{
Fix failure to detach if process exits while detaching on Linux This commit fixes detaching on Linux when some thread exits the whole thread group (process) just while we're detaching. On Linux, a ptracer must detach from each LWP individually, with PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if one of the already-detached threads causes the whole thread group to exit (e.g., simply calls exit), the kernel force-kills the other threads in the group, making them zombie, just as we're still detaching them. Since PTRACE_DETACH against a zombie thread fails with ESRCH, and gdb/gdbserver are not expecting this, the detach fails with an error like: "Can't detach process: No such process.". This patch detects this detach failure as normal, and instead of erroring out, reaps the now-dead thread. New test included, that exercises several different scenarios that cause GDB/GDBserver to error out when it should not. Tested on x86-64 GNU/Linux with {unix, native-gdbserver, native-extended-gdbserver} Note: without the previous fix, the "single-process + continue" variant of the new test would fail with: (gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent continue Continuing. Warning: Could not insert hardware watchpoint 3. Could not insert hardware breakpoints: You may have requested too many hardware breakpoints/watchpoints. Command aborted. (gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue gdb/gdbserver/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * linux-low.c: Change interface to take the target lwp_info pointer directly and return void. Handle detaching from a zombie thread. (linux_detach_lwp_callback): New function. (linux_detach): Detach from the leader thread after detaching from the clone threads. gdb/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * inf-ptrace.c (inf_ptrace_detach_success): New function, factored out from ... (inf_ptrace_detach): ... here. * inf-ptrace.h (inf_ptrace_detach_success): New declaration. * linux-nat.c (get_pending_status): Rename to ... (get_detach_signal): ... this, and return a host signal instead of filling in a wait status. (detach_one_lwp): New function, factored out from detach_callback and adjusted to handle detaching from a zombie thread. (detach_callback): Skip the leader thread. (linux_nat_detach): No longer defer to inf_ptrace_detach to detach the leader thread, nor build a signal string to pass down. Instead, use target_announce_detach, detach_one_lwp and inf_ptrace_detach_success. gdb/testsuite/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * gdb.threads/process-dies-while-detaching.c: New file. * gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
struct thread_info *thread = get_lwp_thread (lwp);
int sig;
Fix failure to detach if process exits while detaching on Linux This commit fixes detaching on Linux when some thread exits the whole thread group (process) just while we're detaching. On Linux, a ptracer must detach from each LWP individually, with PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if one of the already-detached threads causes the whole thread group to exit (e.g., simply calls exit), the kernel force-kills the other threads in the group, making them zombie, just as we're still detaching them. Since PTRACE_DETACH against a zombie thread fails with ESRCH, and gdb/gdbserver are not expecting this, the detach fails with an error like: "Can't detach process: No such process.". This patch detects this detach failure as normal, and instead of erroring out, reaps the now-dead thread. New test included, that exercises several different scenarios that cause GDB/GDBserver to error out when it should not. Tested on x86-64 GNU/Linux with {unix, native-gdbserver, native-extended-gdbserver} Note: without the previous fix, the "single-process + continue" variant of the new test would fail with: (gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent continue Continuing. Warning: Could not insert hardware watchpoint 3. Could not insert hardware breakpoints: You may have requested too many hardware breakpoints/watchpoints. Command aborted. (gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue gdb/gdbserver/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * linux-low.c: Change interface to take the target lwp_info pointer directly and return void. Handle detaching from a zombie thread. (linux_detach_lwp_callback): New function. (linux_detach): Detach from the leader thread after detaching from the clone threads. gdb/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * inf-ptrace.c (inf_ptrace_detach_success): New function, factored out from ... (inf_ptrace_detach): ... here. * inf-ptrace.h (inf_ptrace_detach_success): New declaration. * linux-nat.c (get_pending_status): Rename to ... (get_detach_signal): ... this, and return a host signal instead of filling in a wait status. (detach_one_lwp): New function, factored out from detach_callback and adjusted to handle detaching from a zombie thread. (detach_callback): Skip the leader thread. (linux_nat_detach): No longer defer to inf_ptrace_detach to detach the leader thread, nor build a signal string to pass down. Instead, use target_announce_detach, detach_one_lwp and inf_ptrace_detach_success. gdb/testsuite/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * gdb.threads/process-dies-while-detaching.c: New file. * gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
int lwpid;
/* If there is a pending SIGSTOP, get rid of it. */
Rename "process" to "lwp" throughout. * linux-low.c (all_processes): Rename to... (all_lwps): ... this. (inferior_pid, handle_extended_wait, get_stop_pc): Adjust. (add_process): Rename to ... (add_lwp): ... this. Adjust. (linux_create_inferior): Adjust. (linux_attach_lwp): Adjust. (linux_attach): Adjust. (linux_kill_one_process): Rename to ... (linux_kill_one_lwp): ... this. Adjust. (linux_kill): Adjust. (linux_detach_one_process): Rename to ... (linux_detach_one_lwp): ... this. Adjust. (linux_detach): Adjust. (check_removed_breakpoint): Adjust. (status_pending_p): Adjust. (linux_wait_for_process): Rename to ... (linux_wait_for_lwp): ... this. Adjust. (linux_wait_for_event): Adjust. (send_sigstop): Adjust. (wait_for_sigstop): Adjust. (stop_all_processes): Rename to ... (stop_all_lwps): ... this. (linux_resume_one_process): Rename to ... (linux_resume_one_lwp): ... this. Adjust. (linux_set_resume_request, linux_continue_one_thread) (linux_queue_one_thread, resume_status_pending_p) (usr_store_inferior_registers, regsets_store_inferior_registers) (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Adjust. * linux-low.h (get_process): Rename to ... (get_lwp): ... this. Adjust. (get_thread_process): Rename to ... (get_thread_lwp): ... this. Adjust. (get_process_thread): Rename to ... (get_lwp_thread): ... this. Adjust. (struct process_info): Rename to ... (struct lwp_info): ... this. (all_processes): Rename to ... (all_lwps): ... this. * proc-service.c (ps_lgetregs): Adjust. * thread-db.c (thread_db_create_event, find_one_thread) (maybe_attach_thread, thread_db_get_tls_address): Adjust.
2009-03-17 21:25:35 +01:00
if (lwp->stop_expected)
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Sending SIGCONT to %s\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
target_pid_to_str (ptid_of (thread)));
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
kill_lwp (lwpid_of (thread), SIGCONT);
Rename "process" to "lwp" throughout. * linux-low.c (all_processes): Rename to... (all_lwps): ... this. (inferior_pid, handle_extended_wait, get_stop_pc): Adjust. (add_process): Rename to ... (add_lwp): ... this. Adjust. (linux_create_inferior): Adjust. (linux_attach_lwp): Adjust. (linux_attach): Adjust. (linux_kill_one_process): Rename to ... (linux_kill_one_lwp): ... this. Adjust. (linux_kill): Adjust. (linux_detach_one_process): Rename to ... (linux_detach_one_lwp): ... this. Adjust. (linux_detach): Adjust. (check_removed_breakpoint): Adjust. (status_pending_p): Adjust. (linux_wait_for_process): Rename to ... (linux_wait_for_lwp): ... this. Adjust. (linux_wait_for_event): Adjust. (send_sigstop): Adjust. (wait_for_sigstop): Adjust. (stop_all_processes): Rename to ... (stop_all_lwps): ... this. (linux_resume_one_process): Rename to ... (linux_resume_one_lwp): ... this. Adjust. (linux_set_resume_request, linux_continue_one_thread) (linux_queue_one_thread, resume_status_pending_p) (usr_store_inferior_registers, regsets_store_inferior_registers) (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Adjust. * linux-low.h (get_process): Rename to ... (get_lwp): ... this. Adjust. (get_thread_process): Rename to ... (get_thread_lwp): ... this. Adjust. (get_process_thread): Rename to ... (get_lwp_thread): ... this. Adjust. (struct process_info): Rename to ... (struct lwp_info): ... this. (all_processes): Rename to ... (all_lwps): ... this. * proc-service.c (ps_lgetregs): Adjust. * thread-db.c (thread_db_create_event, find_one_thread) (maybe_attach_thread, thread_db_get_tls_address): Adjust.
2009-03-17 21:25:35 +01:00
lwp->stop_expected = 0;
}
/* Pass on any pending signal for this thread. */
sig = get_detach_signal (thread);
Fix failure to detach if process exits while detaching on Linux This commit fixes detaching on Linux when some thread exits the whole thread group (process) just while we're detaching. On Linux, a ptracer must detach from each LWP individually, with PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if one of the already-detached threads causes the whole thread group to exit (e.g., simply calls exit), the kernel force-kills the other threads in the group, making them zombie, just as we're still detaching them. Since PTRACE_DETACH against a zombie thread fails with ESRCH, and gdb/gdbserver are not expecting this, the detach fails with an error like: "Can't detach process: No such process.". This patch detects this detach failure as normal, and instead of erroring out, reaps the now-dead thread. New test included, that exercises several different scenarios that cause GDB/GDBserver to error out when it should not. Tested on x86-64 GNU/Linux with {unix, native-gdbserver, native-extended-gdbserver} Note: without the previous fix, the "single-process + continue" variant of the new test would fail with: (gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent continue Continuing. Warning: Could not insert hardware watchpoint 3. Could not insert hardware breakpoints: You may have requested too many hardware breakpoints/watchpoints. Command aborted. (gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue gdb/gdbserver/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * linux-low.c: Change interface to take the target lwp_info pointer directly and return void. Handle detaching from a zombie thread. (linux_detach_lwp_callback): New function. (linux_detach): Detach from the leader thread after detaching from the clone threads. gdb/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * inf-ptrace.c (inf_ptrace_detach_success): New function, factored out from ... (inf_ptrace_detach): ... here. * inf-ptrace.h (inf_ptrace_detach_success): New declaration. * linux-nat.c (get_pending_status): Rename to ... (get_detach_signal): ... this, and return a host signal instead of filling in a wait status. (detach_one_lwp): New function, factored out from detach_callback and adjusted to handle detaching from a zombie thread. (detach_callback): Skip the leader thread. (linux_nat_detach): No longer defer to inf_ptrace_detach to detach the leader thread, nor build a signal string to pass down. Instead, use target_announce_detach, detach_one_lwp and inf_ptrace_detach_success. gdb/testsuite/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * gdb.threads/process-dies-while-detaching.c: New file. * gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
/* Preparing to resume may try to write registers, and fail if the
lwp is zombie. If that happens, ignore the error. We'll handle
it below, when detach fails with ESRCH. */
Rewrite TRY/CATCH This rewrites gdb's TRY/CATCH to plain C++ try/catch. The patch was largely written by script, though one change (to a comment in common-exceptions.h) was reverted by hand. gdb/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * xml-support.c: Use C++ exception handling. * x86-linux-nat.c: Use C++ exception handling. * windows-nat.c: Use C++ exception handling. * varobj.c: Use C++ exception handling. * value.c: Use C++ exception handling. * valprint.c: Use C++ exception handling. * valops.c: Use C++ exception handling. * unittests/parse-connection-spec-selftests.c: Use C++ exception handling. * unittests/cli-utils-selftests.c: Use C++ exception handling. * typeprint.c: Use C++ exception handling. * tui/tui.c: Use C++ exception handling. * tracefile-tfile.c: Use C++ exception handling. * top.c: Use C++ exception handling. * thread.c: Use C++ exception handling. * target.c: Use C++ exception handling. * symmisc.c: Use C++ exception handling. * symfile-mem.c: Use C++ exception handling. * stack.c: Use C++ exception handling. * sparc64-linux-tdep.c: Use C++ exception handling. * solib.c: Use C++ exception handling. * solib-svr4.c: Use C++ exception handling. * solib-spu.c: Use C++ exception handling. * solib-frv.c: Use C++ exception handling. * solib-dsbt.c: Use C++ exception handling. * selftest-arch.c: Use C++ exception handling. * s390-tdep.c: Use C++ exception handling. * rust-lang.c: Use C++ exception handling. * rust-exp.y: Use C++ exception handling. * rs6000-tdep.c: Use C++ exception handling. * rs6000-aix-tdep.c: Use C++ exception handling. * riscv-tdep.c: Use C++ exception handling. * remote.c: Use C++ exception handling. * remote-fileio.c: Use C++ exception handling. * record-full.c: Use C++ exception handling. * record-btrace.c: Use C++ exception handling. * python/python.c: Use C++ exception handling. * python/py-value.c: Use C++ exception handling. * python/py-utils.c: Use C++ exception handling. * python/py-unwind.c: Use C++ exception handling. * python/py-type.c: Use C++ exception handling. * python/py-symbol.c: Use C++ exception handling. * python/py-record.c: Use C++ exception handling. * python/py-record-btrace.c: Use C++ exception handling. * python/py-progspace.c: Use C++ exception handling. * python/py-prettyprint.c: Use C++ exception handling. * python/py-param.c: Use C++ exception handling. * python/py-objfile.c: Use C++ exception handling. * python/py-linetable.c: Use C++ exception handling. * python/py-lazy-string.c: Use C++ exception handling. * python/py-infthread.c: Use C++ exception handling. * python/py-inferior.c: Use C++ exception handling. * python/py-gdb-readline.c: Use C++ exception handling. * python/py-framefilter.c: Use C++ exception handling. * python/py-frame.c: Use C++ exception handling. * python/py-finishbreakpoint.c: Use C++ exception handling. * python/py-cmd.c: Use C++ exception handling. * python/py-breakpoint.c: Use C++ exception handling. * python/py-arch.c: Use C++ exception handling. * printcmd.c: Use C++ exception handling. * ppc-linux-tdep.c: Use C++ exception handling. * parse.c: Use C++ exception handling. * p-valprint.c: Use C++ exception handling. * objc-lang.c: Use C++ exception handling. * mi/mi-main.c: Use C++ exception handling. * mi/mi-interp.c: Use C++ exception handling. * mi/mi-cmd-stack.c: Use C++ exception handling. * mi/mi-cmd-break.c: Use C++ exception handling. * main.c: Use C++ exception handling. * linux-thread-db.c: Use C++ exception handling. * linux-tdep.c: Use C++ exception handling. * linux-nat.c: Use C++ exception handling. * linux-fork.c: Use C++ exception handling. * linespec.c: Use C++ exception handling. * language.c: Use C++ exception handling. * jit.c: Use C++ exception handling. * infrun.c: Use C++ exception handling. * infcmd.c: Use C++ exception handling. * infcall.c: Use C++ exception handling. * inf-loop.c: Use C++ exception handling. * i386-tdep.c: Use C++ exception handling. * i386-linux-tdep.c: Use C++ exception handling. * guile/scm-value.c: Use C++ exception handling. * guile/scm-type.c: Use C++ exception handling. * guile/scm-symtab.c: Use C++ exception handling. * guile/scm-symbol.c: Use C++ exception handling. * guile/scm-pretty-print.c: Use C++ exception handling. * guile/scm-ports.c: Use C++ exception handling. * guile/scm-param.c: Use C++ exception handling. * guile/scm-math.c: Use C++ exception handling. * guile/scm-lazy-string.c: Use C++ exception handling. * guile/scm-frame.c: Use C++ exception handling. * guile/scm-disasm.c: Use C++ exception handling. * guile/scm-cmd.c: Use C++ exception handling. * guile/scm-breakpoint.c: Use C++ exception handling. * guile/scm-block.c: Use C++ exception handling. * guile/guile-internal.h: Use C++ exception handling. * gnu-v3-abi.c: Use C++ exception handling. * gdbtypes.c: Use C++ exception handling. * frame.c: Use C++ exception handling. * frame-unwind.c: Use C++ exception handling. * fbsd-tdep.c: Use C++ exception handling. * f-valprint.c: Use C++ exception handling. * exec.c: Use C++ exception handling. * event-top.c: Use C++ exception handling. * event-loop.c: Use C++ exception handling. * eval.c: Use C++ exception handling. * dwarf2read.c: Use C++ exception handling. * dwarf2loc.c: Use C++ exception handling. * dwarf2-frame.c: Use C++ exception handling. * dwarf2-frame-tailcall.c: Use C++ exception handling. * dwarf-index-write.c: Use C++ exception handling. * dwarf-index-cache.c: Use C++ exception handling. * dtrace-probe.c: Use C++ exception handling. * disasm-selftests.c: Use C++ exception handling. * darwin-nat.c: Use C++ exception handling. * cp-valprint.c: Use C++ exception handling. * cp-support.c: Use C++ exception handling. * cp-abi.c: Use C++ exception handling. * corelow.c: Use C++ exception handling. * completer.c: Use C++ exception handling. * compile/compile-object-run.c: Use C++ exception handling. * compile/compile-object-load.c: Use C++ exception handling. * compile/compile-cplus-symbols.c: Use C++ exception handling. * compile/compile-c-symbols.c: Use C++ exception handling. * common/selftest.c: Use C++ exception handling. * common/new-op.c: Use C++ exception handling. * cli/cli-script.c: Use C++ exception handling. * cli/cli-interp.c: Use C++ exception handling. * cli/cli-cmds.c: Use C++ exception handling. * c-varobj.c: Use C++ exception handling. * btrace.c: Use C++ exception handling. * breakpoint.c: Use C++ exception handling. * break-catch-throw.c: Use C++ exception handling. * arch-utils.c: Use C++ exception handling. * amd64-tdep.c: Use C++ exception handling. * ada-valprint.c: Use C++ exception handling. * ada-typeprint.c: Use C++ exception handling. * ada-lang.c: Use C++ exception handling. * aarch64-tdep.c: Use C++ exception handling. gdb/gdbserver/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * server.c: Use C++ exception handling. * linux-low.c: Use C++ exception handling. * gdbreplay.c: Use C++ exception handling.
2019-04-04 00:02:42 +02:00
try
Fix failure to detach if process exits while detaching on Linux This commit fixes detaching on Linux when some thread exits the whole thread group (process) just while we're detaching. On Linux, a ptracer must detach from each LWP individually, with PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if one of the already-detached threads causes the whole thread group to exit (e.g., simply calls exit), the kernel force-kills the other threads in the group, making them zombie, just as we're still detaching them. Since PTRACE_DETACH against a zombie thread fails with ESRCH, and gdb/gdbserver are not expecting this, the detach fails with an error like: "Can't detach process: No such process.". This patch detects this detach failure as normal, and instead of erroring out, reaps the now-dead thread. New test included, that exercises several different scenarios that cause GDB/GDBserver to error out when it should not. Tested on x86-64 GNU/Linux with {unix, native-gdbserver, native-extended-gdbserver} Note: without the previous fix, the "single-process + continue" variant of the new test would fail with: (gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent continue Continuing. Warning: Could not insert hardware watchpoint 3. Could not insert hardware breakpoints: You may have requested too many hardware breakpoints/watchpoints. Command aborted. (gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue gdb/gdbserver/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * linux-low.c: Change interface to take the target lwp_info pointer directly and return void. Handle detaching from a zombie thread. (linux_detach_lwp_callback): New function. (linux_detach): Detach from the leader thread after detaching from the clone threads. gdb/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * inf-ptrace.c (inf_ptrace_detach_success): New function, factored out from ... (inf_ptrace_detach): ... here. * inf-ptrace.h (inf_ptrace_detach_success): New declaration. * linux-nat.c (get_pending_status): Rename to ... (get_detach_signal): ... this, and return a host signal instead of filling in a wait status. (detach_one_lwp): New function, factored out from detach_callback and adjusted to handle detaching from a zombie thread. (detach_callback): Skip the leader thread. (linux_nat_detach): No longer defer to inf_ptrace_detach to detach the leader thread, nor build a signal string to pass down. Instead, use target_announce_detach, detach_one_lwp and inf_ptrace_detach_success. gdb/testsuite/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * gdb.threads/process-dies-while-detaching.c: New file. * gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
{
/* Flush any pending changes to the process's registers. */
regcache_invalidate_thread (thread);
/* Finally, let it resume. */
gdbserver/linux-low: turn 'prepare_to_resume' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'prepare_to_resume' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <low_prepare_to_resume>: Declare. * linux-low.cc (linux_process_target::low_prepare_to_resume): Define. Update the callers below: (linux_process_target::resume_one_lwp_throw) (linux_process_target::low_prepare_to_resume) * linux-x86-low.cc (class x86_target) <low_prepare_to_resume>: Declare. (x86_target::low_prepare_to_resume): Define. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <low_prepare_to_resume>: Declare. (aarch64_target::low_prepare_to_resume): Define. (the_low_target): Remove the op field. * linux-arm-low.cc (class arm_target) <low_prepare_to_resume>: Declare. (arm_prepare_to_resume): Turn into... (arm_target::low_prepare_to_resume): ...this. (the_low_target): Remove the op field. * linux-mips-low.cc (class mips_target) <low_prepare_to_resume>: Declare. (mips_linux_prepare_to_resume): Turn into... (mips_target::low_prepare_to_resume): ...this. (the_low_target): Remove the op field. * linux-bfin-low.cc (the_low_target): Remove the op field. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:29 +02:00
low_prepare_to_resume (lwp);
Fix failure to detach if process exits while detaching on Linux This commit fixes detaching on Linux when some thread exits the whole thread group (process) just while we're detaching. On Linux, a ptracer must detach from each LWP individually, with PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if one of the already-detached threads causes the whole thread group to exit (e.g., simply calls exit), the kernel force-kills the other threads in the group, making them zombie, just as we're still detaching them. Since PTRACE_DETACH against a zombie thread fails with ESRCH, and gdb/gdbserver are not expecting this, the detach fails with an error like: "Can't detach process: No such process.". This patch detects this detach failure as normal, and instead of erroring out, reaps the now-dead thread. New test included, that exercises several different scenarios that cause GDB/GDBserver to error out when it should not. Tested on x86-64 GNU/Linux with {unix, native-gdbserver, native-extended-gdbserver} Note: without the previous fix, the "single-process + continue" variant of the new test would fail with: (gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent continue Continuing. Warning: Could not insert hardware watchpoint 3. Could not insert hardware breakpoints: You may have requested too many hardware breakpoints/watchpoints. Command aborted. (gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue gdb/gdbserver/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * linux-low.c: Change interface to take the target lwp_info pointer directly and return void. Handle detaching from a zombie thread. (linux_detach_lwp_callback): New function. (linux_detach): Detach from the leader thread after detaching from the clone threads. gdb/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * inf-ptrace.c (inf_ptrace_detach_success): New function, factored out from ... (inf_ptrace_detach): ... here. * inf-ptrace.h (inf_ptrace_detach_success): New declaration. * linux-nat.c (get_pending_status): Rename to ... (get_detach_signal): ... this, and return a host signal instead of filling in a wait status. (detach_one_lwp): New function, factored out from detach_callback and adjusted to handle detaching from a zombie thread. (detach_callback): Skip the leader thread. (linux_nat_detach): No longer defer to inf_ptrace_detach to detach the leader thread, nor build a signal string to pass down. Instead, use target_announce_detach, detach_one_lwp and inf_ptrace_detach_success. gdb/testsuite/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * gdb.threads/process-dies-while-detaching.c: New file. * gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
}
Rename gdb exception types This renames the gdb exception types. The old types were only needed due to the macros in common-exception.h that are now gone. The intermediate layer of gdb_exception_RETURN_MASK_ALL did not seem needed, so this patch removes it entirely. gdb/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * common/common-exceptions.h (gdb_exception_RETURN_MASK_ALL): Remove. (gdb_exception_error): Rename from gdb_exception_RETURN_MASK_ERROR. (gdb_exception_quit): Rename from gdb_exception_RETURN_MASK_QUIT. (gdb_quit_bad_alloc): Update. * aarch64-tdep.c: Update. * ada-lang.c: Update. * ada-typeprint.c: Update. * ada-valprint.c: Update. * amd64-tdep.c: Update. * arch-utils.c: Update. * break-catch-throw.c: Update. * breakpoint.c: Update. * btrace.c: Update. * c-varobj.c: Update. * cli/cli-cmds.c: Update. * cli/cli-interp.c: Update. * cli/cli-script.c: Update. * common/common-exceptions.c: Update. * common/new-op.c: Update. * common/selftest.c: Update. * compile/compile-c-symbols.c: Update. * compile/compile-cplus-symbols.c: Update. * compile/compile-object-load.c: Update. * compile/compile-object-run.c: Update. * completer.c: Update. * corelow.c: Update. * cp-abi.c: Update. * cp-support.c: Update. * cp-valprint.c: Update. * darwin-nat.c: Update. * disasm-selftests.c: Update. * dtrace-probe.c: Update. * dwarf-index-cache.c: Update. * dwarf-index-write.c: Update. * dwarf2-frame-tailcall.c: Update. * dwarf2-frame.c: Update. * dwarf2loc.c: Update. * dwarf2read.c: Update. * eval.c: Update. * event-loop.c: Update. * event-top.c: Update. * exec.c: Update. * f-valprint.c: Update. * fbsd-tdep.c: Update. * frame-unwind.c: Update. * frame.c: Update. * gdbtypes.c: Update. * gnu-v3-abi.c: Update. * guile/guile-internal.h: Update. * guile/scm-block.c: Update. * guile/scm-breakpoint.c: Update. * guile/scm-cmd.c: Update. * guile/scm-disasm.c: Update. * guile/scm-frame.c: Update. * guile/scm-lazy-string.c: Update. * guile/scm-math.c: Update. * guile/scm-param.c: Update. * guile/scm-ports.c: Update. * guile/scm-pretty-print.c: Update. * guile/scm-symbol.c: Update. * guile/scm-symtab.c: Update. * guile/scm-type.c: Update. * guile/scm-value.c: Update. * i386-linux-tdep.c: Update. * i386-tdep.c: Update. * inf-loop.c: Update. * infcall.c: Update. * infcmd.c: Update. * infrun.c: Update. * jit.c: Update. * language.c: Update. * linespec.c: Update. * linux-fork.c: Update. * linux-nat.c: Update. * linux-tdep.c: Update. * linux-thread-db.c: Update. * main.c: Update. * mi/mi-cmd-break.c: Update. * mi/mi-cmd-stack.c: Update. * mi/mi-interp.c: Update. * mi/mi-main.c: Update. * objc-lang.c: Update. * p-valprint.c: Update. * parse.c: Update. * ppc-linux-tdep.c: Update. * printcmd.c: Update. * python/py-arch.c: Update. * python/py-breakpoint.c: Update. * python/py-cmd.c: Update. * python/py-finishbreakpoint.c: Update. * python/py-frame.c: Update. * python/py-framefilter.c: Update. * python/py-gdb-readline.c: Update. * python/py-inferior.c: Update. * python/py-infthread.c: Update. * python/py-lazy-string.c: Update. * python/py-linetable.c: Update. * python/py-objfile.c: Update. * python/py-param.c: Update. * python/py-prettyprint.c: Update. * python/py-progspace.c: Update. * python/py-record-btrace.c: Update. * python/py-record.c: Update. * python/py-symbol.c: Update. * python/py-type.c: Update. * python/py-unwind.c: Update. * python/py-utils.c: Update. * python/py-value.c: Update. * python/python.c: Update. * record-btrace.c: Update. * record-full.c: Update. * remote-fileio.c: Update. * remote.c: Update. * riscv-tdep.c: Update. * rs6000-aix-tdep.c: Update. * rs6000-tdep.c: Update. * rust-exp.y: Update. * rust-lang.c: Update. * s390-tdep.c: Update. * selftest-arch.c: Update. * solib-dsbt.c: Update. * solib-frv.c: Update. * solib-spu.c: Update. * solib-svr4.c: Update. * solib.c: Update. * sparc64-linux-tdep.c: Update. * stack.c: Update. * symfile-mem.c: Update. * symmisc.c: Update. * target.c: Update. * thread.c: Update. * top.c: Update. * tracefile-tfile.c: Update. * tui/tui.c: Update. * typeprint.c: Update. * unittests/cli-utils-selftests.c: Update. * unittests/parse-connection-spec-selftests.c: Update. * valops.c: Update. * valprint.c: Update. * value.c: Update. * varobj.c: Update. * windows-nat.c: Update. * x86-linux-nat.c: Update. * xml-support.c: Update. gdb/gdbserver/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * gdbreplay.c: Update. * linux-low.c: Update. * server.c: Update.
2019-04-03 23:59:07 +02:00
catch (const gdb_exception_error &ex)
Fix failure to detach if process exits while detaching on Linux This commit fixes detaching on Linux when some thread exits the whole thread group (process) just while we're detaching. On Linux, a ptracer must detach from each LWP individually, with PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if one of the already-detached threads causes the whole thread group to exit (e.g., simply calls exit), the kernel force-kills the other threads in the group, making them zombie, just as we're still detaching them. Since PTRACE_DETACH against a zombie thread fails with ESRCH, and gdb/gdbserver are not expecting this, the detach fails with an error like: "Can't detach process: No such process.". This patch detects this detach failure as normal, and instead of erroring out, reaps the now-dead thread. New test included, that exercises several different scenarios that cause GDB/GDBserver to error out when it should not. Tested on x86-64 GNU/Linux with {unix, native-gdbserver, native-extended-gdbserver} Note: without the previous fix, the "single-process + continue" variant of the new test would fail with: (gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent continue Continuing. Warning: Could not insert hardware watchpoint 3. Could not insert hardware breakpoints: You may have requested too many hardware breakpoints/watchpoints. Command aborted. (gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue gdb/gdbserver/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * linux-low.c: Change interface to take the target lwp_info pointer directly and return void. Handle detaching from a zombie thread. (linux_detach_lwp_callback): New function. (linux_detach): Detach from the leader thread after detaching from the clone threads. gdb/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * inf-ptrace.c (inf_ptrace_detach_success): New function, factored out from ... (inf_ptrace_detach): ... here. * inf-ptrace.h (inf_ptrace_detach_success): New declaration. * linux-nat.c (get_pending_status): Rename to ... (get_detach_signal): ... this, and return a host signal instead of filling in a wait status. (detach_one_lwp): New function, factored out from detach_callback and adjusted to handle detaching from a zombie thread. (detach_callback): Skip the leader thread. (linux_nat_detach): No longer defer to inf_ptrace_detach to detach the leader thread, nor build a signal string to pass down. Instead, use target_announce_detach, detach_one_lwp and inf_ptrace_detach_success. gdb/testsuite/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * gdb.threads/process-dies-while-detaching.c: New file. * gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
{
if (!check_ptrace_stopped_lwp_gone (lwp))
Replace throw_exception with throw in some cases This replaces throw_exception with "throw;" when possible. This was written by script. The rule that is followed is that uses of the form: catch (... &name) { ... throw_exception (name); } ... can be rewritten. This should always be safe, because exceptions are caught by const reference, and therefore can't be modified in the body of the catch. gdb/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * valops.c (value_rtti_indirect_type): Replace throw_exception with throw. * tracefile-tfile.c (tfile_target_open): Replace throw_exception with throw. * thread.c (thr_try_catch_cmd): Replace throw_exception with throw. * target.c (target_translate_tls_address): Replace throw_exception with throw. * stack.c (frame_apply_command_count): Replace throw_exception with throw. * solib-spu.c (append_ocl_sos): Replace throw_exception with throw. * s390-tdep.c (s390_frame_unwind_cache): Replace throw_exception with throw. * rs6000-tdep.c (rs6000_frame_cache) (rs6000_epilogue_frame_cache): Replace throw_exception with throw. * remote.c: Replace throw_exception with throw. * record-full.c (record_full_message, record_full_wait_1) (record_full_restore): Replace throw_exception with throw. * record-btrace.c: (get_thread_current_frame_id, record_btrace_start_replaying) (cmd_record_btrace_bts_start, cmd_record_btrace_pt_start) (cmd_record_btrace_start): Replace throw_exception with throw. * parse.c (parse_exp_in_context_1): Replace throw_exception with throw. * linux-nat.c (detach_one_lwp, linux_resume_one_lwp) (resume_stopped_resumed_lwps): Replace throw_exception with throw. * linespec.c: (find_linespec_symbols): Replace throw_exception with throw. * infrun.c (displaced_step_prepare, resume): Replace throw_exception with throw. * infcmd.c (post_create_inferior): Replace throw_exception with throw. * inf-loop.c (inferior_event_handler): Replace throw_exception with throw. * i386-tdep.c (i386_frame_cache, i386_epilogue_frame_cache) (i386_sigtramp_frame_cache): Replace throw_exception with throw. * frame.c (frame_unwind_pc, get_prev_frame_if_no_cycle) (get_prev_frame_always, get_frame_pc_if_available) (get_frame_address_in_block_if_available, get_frame_language): Replace throw_exception with throw. * frame-unwind.c (frame_unwind_try_unwinder): Replace throw_exception with throw. * eval.c (fetch_subexp_value, evaluate_var_value) (evaluate_funcall, evaluate_subexp_standard): Replace throw_exception with throw. * dwarf2loc.c (call_site_find_chain) (dwarf2_evaluate_loc_desc_full, dwarf2_locexpr_baton_eval): Replace throw_exception with throw. * dwarf2-frame.c (dwarf2_frame_cache): Replace throw_exception with throw. * darwin-nat.c (darwin_attach_pid): Replace throw_exception with throw. * cp-abi.c (baseclass_offset): Replace throw_exception with throw. * completer.c (complete_line_internal): Replace throw_exception with throw. * compile/compile-object-run.c (compile_object_run): Replace throw_exception with throw. * cli/cli-script.c (process_next_line): Replace throw_exception with throw. * btrace.c (btrace_compute_ftrace_pt, btrace_compute_ftrace) (btrace_enable, btrace_maint_update_pt_packets): Replace throw_exception with throw. * breakpoint.c (create_breakpoint, save_breakpoints): Replace throw_exception with throw. * break-catch-throw.c (re_set_exception_catchpoint): Replace throw_exception with throw. * amd64-tdep.c (amd64_frame_cache, amd64_sigtramp_frame_cache) (amd64_epilogue_frame_cache): Replace throw_exception with throw. * aarch64-tdep.c (aarch64_make_prologue_cache) (aarch64_make_stub_cache): Replace throw_exception with throw. gdb/gdbserver/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * linux-low.c (linux_detach_one_lwp): Replace throw_exception with throw. (linux_resume_one_lwp): Likewise.
2019-01-28 18:45:45 +01:00
throw;
Fix failure to detach if process exits while detaching on Linux This commit fixes detaching on Linux when some thread exits the whole thread group (process) just while we're detaching. On Linux, a ptracer must detach from each LWP individually, with PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if one of the already-detached threads causes the whole thread group to exit (e.g., simply calls exit), the kernel force-kills the other threads in the group, making them zombie, just as we're still detaching them. Since PTRACE_DETACH against a zombie thread fails with ESRCH, and gdb/gdbserver are not expecting this, the detach fails with an error like: "Can't detach process: No such process.". This patch detects this detach failure as normal, and instead of erroring out, reaps the now-dead thread. New test included, that exercises several different scenarios that cause GDB/GDBserver to error out when it should not. Tested on x86-64 GNU/Linux with {unix, native-gdbserver, native-extended-gdbserver} Note: without the previous fix, the "single-process + continue" variant of the new test would fail with: (gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent continue Continuing. Warning: Could not insert hardware watchpoint 3. Could not insert hardware breakpoints: You may have requested too many hardware breakpoints/watchpoints. Command aborted. (gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue gdb/gdbserver/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * linux-low.c: Change interface to take the target lwp_info pointer directly and return void. Handle detaching from a zombie thread. (linux_detach_lwp_callback): New function. (linux_detach): Detach from the leader thread after detaching from the clone threads. gdb/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * inf-ptrace.c (inf_ptrace_detach_success): New function, factored out from ... (inf_ptrace_detach): ... here. * inf-ptrace.h (inf_ptrace_detach_success): New declaration. * linux-nat.c (get_pending_status): Rename to ... (get_detach_signal): ... this, and return a host signal instead of filling in a wait status. (detach_one_lwp): New function, factored out from detach_callback and adjusted to handle detaching from a zombie thread. (detach_callback): Skip the leader thread. (linux_nat_detach): No longer defer to inf_ptrace_detach to detach the leader thread, nor build a signal string to pass down. Instead, use target_announce_detach, detach_one_lwp and inf_ptrace_detach_success. gdb/testsuite/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * gdb.threads/process-dies-while-detaching.c: New file. * gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
}
lwpid = lwpid_of (thread);
if (ptrace (PTRACE_DETACH, lwpid, (PTRACE_TYPE_ARG3) 0,
(PTRACE_TYPE_ARG4) (long) sig) < 0)
Fix failure to detach if process exits while detaching on Linux This commit fixes detaching on Linux when some thread exits the whole thread group (process) just while we're detaching. On Linux, a ptracer must detach from each LWP individually, with PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if one of the already-detached threads causes the whole thread group to exit (e.g., simply calls exit), the kernel force-kills the other threads in the group, making them zombie, just as we're still detaching them. Since PTRACE_DETACH against a zombie thread fails with ESRCH, and gdb/gdbserver are not expecting this, the detach fails with an error like: "Can't detach process: No such process.". This patch detects this detach failure as normal, and instead of erroring out, reaps the now-dead thread. New test included, that exercises several different scenarios that cause GDB/GDBserver to error out when it should not. Tested on x86-64 GNU/Linux with {unix, native-gdbserver, native-extended-gdbserver} Note: without the previous fix, the "single-process + continue" variant of the new test would fail with: (gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent continue Continuing. Warning: Could not insert hardware watchpoint 3. Could not insert hardware breakpoints: You may have requested too many hardware breakpoints/watchpoints. Command aborted. (gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue gdb/gdbserver/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * linux-low.c: Change interface to take the target lwp_info pointer directly and return void. Handle detaching from a zombie thread. (linux_detach_lwp_callback): New function. (linux_detach): Detach from the leader thread after detaching from the clone threads. gdb/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * inf-ptrace.c (inf_ptrace_detach_success): New function, factored out from ... (inf_ptrace_detach): ... here. * inf-ptrace.h (inf_ptrace_detach_success): New declaration. * linux-nat.c (get_pending_status): Rename to ... (get_detach_signal): ... this, and return a host signal instead of filling in a wait status. (detach_one_lwp): New function, factored out from detach_callback and adjusted to handle detaching from a zombie thread. (detach_callback): Skip the leader thread. (linux_nat_detach): No longer defer to inf_ptrace_detach to detach the leader thread, nor build a signal string to pass down. Instead, use target_announce_detach, detach_one_lwp and inf_ptrace_detach_success. gdb/testsuite/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * gdb.threads/process-dies-while-detaching.c: New file. * gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
{
int save_errno = errno;
/* We know the thread exists, so ESRCH must mean the lwp is
zombie. This can happen if one of the already-detached
threads exits the whole thread group. In that case we're
still attached, and must reap the lwp. */
if (save_errno == ESRCH)
{
int ret, status;
ret = my_waitpid (lwpid, &status, __WALL);
if (ret == -1)
{
warning (_("Couldn't reap LWP %d while detaching: %s"),
lwpid, safe_strerror (errno));
Fix failure to detach if process exits while detaching on Linux This commit fixes detaching on Linux when some thread exits the whole thread group (process) just while we're detaching. On Linux, a ptracer must detach from each LWP individually, with PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if one of the already-detached threads causes the whole thread group to exit (e.g., simply calls exit), the kernel force-kills the other threads in the group, making them zombie, just as we're still detaching them. Since PTRACE_DETACH against a zombie thread fails with ESRCH, and gdb/gdbserver are not expecting this, the detach fails with an error like: "Can't detach process: No such process.". This patch detects this detach failure as normal, and instead of erroring out, reaps the now-dead thread. New test included, that exercises several different scenarios that cause GDB/GDBserver to error out when it should not. Tested on x86-64 GNU/Linux with {unix, native-gdbserver, native-extended-gdbserver} Note: without the previous fix, the "single-process + continue" variant of the new test would fail with: (gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent continue Continuing. Warning: Could not insert hardware watchpoint 3. Could not insert hardware breakpoints: You may have requested too many hardware breakpoints/watchpoints. Command aborted. (gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue gdb/gdbserver/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * linux-low.c: Change interface to take the target lwp_info pointer directly and return void. Handle detaching from a zombie thread. (linux_detach_lwp_callback): New function. (linux_detach): Detach from the leader thread after detaching from the clone threads. gdb/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * inf-ptrace.c (inf_ptrace_detach_success): New function, factored out from ... (inf_ptrace_detach): ... here. * inf-ptrace.h (inf_ptrace_detach_success): New declaration. * linux-nat.c (get_pending_status): Rename to ... (get_detach_signal): ... this, and return a host signal instead of filling in a wait status. (detach_one_lwp): New function, factored out from detach_callback and adjusted to handle detaching from a zombie thread. (detach_callback): Skip the leader thread. (linux_nat_detach): No longer defer to inf_ptrace_detach to detach the leader thread, nor build a signal string to pass down. Instead, use target_announce_detach, detach_one_lwp and inf_ptrace_detach_success. gdb/testsuite/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * gdb.threads/process-dies-while-detaching.c: New file. * gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
}
else if (!WIFEXITED (status) && !WIFSIGNALED (status))
{
warning (_("Reaping LWP %d while detaching "
"returned unexpected status 0x%x"),
lwpid, status);
}
}
else
{
error (_("Can't detach %s: %s"),
target_pid_to_str (ptid_of (thread)),
safe_strerror (save_errno));
Fix failure to detach if process exits while detaching on Linux This commit fixes detaching on Linux when some thread exits the whole thread group (process) just while we're detaching. On Linux, a ptracer must detach from each LWP individually, with PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if one of the already-detached threads causes the whole thread group to exit (e.g., simply calls exit), the kernel force-kills the other threads in the group, making them zombie, just as we're still detaching them. Since PTRACE_DETACH against a zombie thread fails with ESRCH, and gdb/gdbserver are not expecting this, the detach fails with an error like: "Can't detach process: No such process.". This patch detects this detach failure as normal, and instead of erroring out, reaps the now-dead thread. New test included, that exercises several different scenarios that cause GDB/GDBserver to error out when it should not. Tested on x86-64 GNU/Linux with {unix, native-gdbserver, native-extended-gdbserver} Note: without the previous fix, the "single-process + continue" variant of the new test would fail with: (gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent continue Continuing. Warning: Could not insert hardware watchpoint 3. Could not insert hardware breakpoints: You may have requested too many hardware breakpoints/watchpoints. Command aborted. (gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue gdb/gdbserver/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * linux-low.c: Change interface to take the target lwp_info pointer directly and return void. Handle detaching from a zombie thread. (linux_detach_lwp_callback): New function. (linux_detach): Detach from the leader thread after detaching from the clone threads. gdb/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * inf-ptrace.c (inf_ptrace_detach_success): New function, factored out from ... (inf_ptrace_detach): ... here. * inf-ptrace.h (inf_ptrace_detach_success): New declaration. * linux-nat.c (get_pending_status): Rename to ... (get_detach_signal): ... this, and return a host signal instead of filling in a wait status. (detach_one_lwp): New function, factored out from detach_callback and adjusted to handle detaching from a zombie thread. (detach_callback): Skip the leader thread. (linux_nat_detach): No longer defer to inf_ptrace_detach to detach the leader thread, nor build a signal string to pass down. Instead, use target_announce_detach, detach_one_lwp and inf_ptrace_detach_success. gdb/testsuite/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * gdb.threads/process-dies-while-detaching.c: New file. * gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
}
}
else if (debug_threads)
{
debug_printf ("PTRACE_DETACH (%s, %s, 0) (OK)\n",
target_pid_to_str (ptid_of (thread)),
strsignal (sig));
}
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
delete_lwp (lwp);
Fix failure to detach if process exits while detaching on Linux This commit fixes detaching on Linux when some thread exits the whole thread group (process) just while we're detaching. On Linux, a ptracer must detach from each LWP individually, with PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if one of the already-detached threads causes the whole thread group to exit (e.g., simply calls exit), the kernel force-kills the other threads in the group, making them zombie, just as we're still detaching them. Since PTRACE_DETACH against a zombie thread fails with ESRCH, and gdb/gdbserver are not expecting this, the detach fails with an error like: "Can't detach process: No such process.". This patch detects this detach failure as normal, and instead of erroring out, reaps the now-dead thread. New test included, that exercises several different scenarios that cause GDB/GDBserver to error out when it should not. Tested on x86-64 GNU/Linux with {unix, native-gdbserver, native-extended-gdbserver} Note: without the previous fix, the "single-process + continue" variant of the new test would fail with: (gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent continue Continuing. Warning: Could not insert hardware watchpoint 3. Could not insert hardware breakpoints: You may have requested too many hardware breakpoints/watchpoints. Command aborted. (gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue gdb/gdbserver/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * linux-low.c: Change interface to take the target lwp_info pointer directly and return void. Handle detaching from a zombie thread. (linux_detach_lwp_callback): New function. (linux_detach): Detach from the leader thread after detaching from the clone threads. gdb/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * inf-ptrace.c (inf_ptrace_detach_success): New function, factored out from ... (inf_ptrace_detach): ... here. * inf-ptrace.h (inf_ptrace_detach_success): New declaration. * linux-nat.c (get_pending_status): Rename to ... (get_detach_signal): ... this, and return a host signal instead of filling in a wait status. (detach_one_lwp): New function, factored out from detach_callback and adjusted to handle detaching from a zombie thread. (detach_callback): Skip the leader thread. (linux_nat_detach): No longer defer to inf_ptrace_detach to detach the leader thread, nor build a signal string to pass down. Instead, use target_announce_detach, detach_one_lwp and inf_ptrace_detach_success. gdb/testsuite/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * gdb.threads/process-dies-while-detaching.c: New file. * gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
}
int
linux_process_target::detach (process_info *process)
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
{
Fix failure to detach if process exits while detaching on Linux This commit fixes detaching on Linux when some thread exits the whole thread group (process) just while we're detaching. On Linux, a ptracer must detach from each LWP individually, with PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if one of the already-detached threads causes the whole thread group to exit (e.g., simply calls exit), the kernel force-kills the other threads in the group, making them zombie, just as we're still detaching them. Since PTRACE_DETACH against a zombie thread fails with ESRCH, and gdb/gdbserver are not expecting this, the detach fails with an error like: "Can't detach process: No such process.". This patch detects this detach failure as normal, and instead of erroring out, reaps the now-dead thread. New test included, that exercises several different scenarios that cause GDB/GDBserver to error out when it should not. Tested on x86-64 GNU/Linux with {unix, native-gdbserver, native-extended-gdbserver} Note: without the previous fix, the "single-process + continue" variant of the new test would fail with: (gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent continue Continuing. Warning: Could not insert hardware watchpoint 3. Could not insert hardware breakpoints: You may have requested too many hardware breakpoints/watchpoints. Command aborted. (gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue gdb/gdbserver/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * linux-low.c: Change interface to take the target lwp_info pointer directly and return void. Handle detaching from a zombie thread. (linux_detach_lwp_callback): New function. (linux_detach): Detach from the leader thread after detaching from the clone threads. gdb/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * inf-ptrace.c (inf_ptrace_detach_success): New function, factored out from ... (inf_ptrace_detach): ... here. * inf-ptrace.h (inf_ptrace_detach_success): New declaration. * linux-nat.c (get_pending_status): Rename to ... (get_detach_signal): ... this, and return a host signal instead of filling in a wait status. (detach_one_lwp): New function, factored out from detach_callback and adjusted to handle detaching from a zombie thread. (detach_callback): Skip the leader thread. (linux_nat_detach): No longer defer to inf_ptrace_detach to detach the leader thread, nor build a signal string to pass down. Instead, use target_announce_detach, detach_one_lwp and inf_ptrace_detach_success. gdb/testsuite/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * gdb.threads/process-dies-while-detaching.c: New file. * gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
struct lwp_info *main_lwp;
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
gdbserver: Fix non-stop / fork / step-over issues Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html This adds a test that has a multithreaded program have several threads continuously fork, while another thread continuously steps over a breakpoint. This exposes several intertwined issues, which this patch addresses: - When we're stopping and suspending threads, some thread may fork, and we missed setting its suspend count to 1, like we do when a new clone/thread is detected. When we next unsuspend threads, the fork child's suspend count goes below 0, which is bogus and fails an assertion. - If a step-over is cancelled because a signal arrives, but then gdb is not interested in the signal, we pass the signal straight back to the inferior. However, we miss that we need to re-increment the suspend counts of all other threads that had been paused for the step-over. As a result, other threads indefinitely end up stuck stopped. - If a detach request comes in just while gdbserver is handling a step-over (in the test at hand, this is GDB detaching the fork child), gdbserver internal errors in stabilize_thread's helpers, which assert that all thread's suspend counts are 0 (otherwise we wouldn't be able to move threads out of the jump pads). The suspend counts aren't 0 while a step-over is in progress, because all threads but the one stepping past the breakpoint must remain paused until the step-over finishes and the breakpoint can be reinserted. - Occasionally, we see "BAD - reinserting but not stepping." being output (from within linux_resume_one_lwp_throw). That was because GDB pokes memory while gdbserver is busy with a step-over, and that suspends threads, and then re-resumes them with proceed_one_lwp, which missed another reason to tell linux_resume_one_lwp that the thread should be set back to stepping. - In a couple places, we were resuming threads that are meant to be suspended. E.g., when a vCont;c/s request for thread B comes in just while gdbserver is stepping thread A past a breakpoint. The resume for thread B must be deferred until the step-over finishes. - The test runs with both "set detach-on-fork" on and off. When off, it exercises the case of GDB detaching the fork child explicitly. When on, it exercises the case of gdb resuming the child explicitly. In the "off" case, gdb seems to exponentially become slower as new inferiors are created. This is _very_ noticeable as with only 100 inferiors gdb is crawling already, which makes the test take quite a bit to run. For that reason, I've disabled the "off" variant for now. gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * target/waitstatus.h (enum target_stop_reason) <TARGET_STOPPED_BY_SINGLE_STEP>: New value. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the fork child's suspend count if stopping and suspending threads. (check_stopped_by_breakpoint): If stopped by trace, set the LWP's stop reason to TARGET_STOPPED_BY_SINGLE_STEP. (linux_detach): Complete an ongoing step-over. (lwp_suspended_inc, lwp_suspended_decr): New functions. Use throughout. (resume_stopped_resumed_lwps): Don't resume a suspended thread. (linux_wait_1): If passing a signal to the inferior after finishing a step-over, unsuspend and re-resume all lwps. If we see a single-step event but the thread should be continuing, don't pass the trap to gdb. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use internal_error instead of gdb_assert. (enqueue_pending_signal): New function. (check_ptrace_stopped_lwp_gone): Add debug output. (start_step_over): Use internal_error instead of gdb_assert. (complete_ongoing_step_over): New function. (linux_resume_one_thread): Don't resume a suspended thread. (proceed_one_lwp): If the LWP is stepping over a breakpoint, reset it stepping. gdb/testsuite/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * gdb.threads/forking-threads-plus-breakpoint.exp: New file. * gdb.threads/forking-threads-plus-breakpoint.c: New file.
2015-08-06 11:30:18 +02:00
/* As there's a step over already in progress, let it finish first,
otherwise nesting a stabilize_threads operation on top gets real
messy. */
complete_ongoing_step_over ();
/* Stop all threads before detaching. First, ptrace requires that
[gdb] Fix more typos in comments (2) Fix typos in comments. NFC. Tested on x86_64-linux. gdb/ChangeLog: 2019-10-26 Tom de Vries <tdevries@suse.de> * aarch64-linux-tdep.c: Fix typos in comments. * aarch64-tdep.c: Same. * ada-lang.c: Same. * amd64-nat.c: Same. * arc-tdep.c: Same. * arch/aarch64-insn.c: Same. * block.c: Same. * breakpoint.h: Same. * btrace.h: Same. * c-varobj.c: Same. * cli/cli-decode.c: Same. * cli/cli-script.c: Same. * cli/cli-utils.h: Same. * coff-pe-read.c: Same. * coffread.c: Same. * compile/compile-cplus-symbols.c: Same. * compile/compile-object-run.c: Same. * completer.c: Same. * corelow.c: Same. * cp-support.c: Same. * demangle.c: Same. * dwarf-index-write.c: Same. * dwarf2-frame.c: Same. * dwarf2-frame.h: Same. * eval.c: Same. * frame-base.h: Same. * frame.h: Same. * gdbcmd.h: Same. * gdbtypes.h: Same. * gnu-nat.c: Same. * guile/scm-objfile.c: Same. * i386-tdep.c: Same. * i386-tdep.h: Same. * infcall.c: Same. * infcall.h: Same. * linux-nat.c: Same. * m68k-tdep.c: Same. * macroexp.c: Same. * memattr.c: Same. * mi/mi-cmd-disas.c: Same. * mi/mi-getopt.h: Same. * mi/mi-main.c: Same. * minsyms.c: Same. * nat/aarch64-sve-linux-sigcontext.h: Same. * objfiles.h: Same. * ppc-linux-nat.c: Same. * ppc-linux-tdep.c: Same. * ppc-tdep.h: Same. * progspace.h: Same. * prologue-value.h: Same. * python/py-evtregistry.c: Same. * python/py-instruction.h: Same. * record-btrace.c: Same. * record-full.c: Same. * remote.c: Same. * rs6000-tdep.c: Same. * ser-tcp.c: Same. * sol-thread.c: Same. * sparc-sol2-tdep.c: Same. * sparc64-tdep.c: Same. * stabsread.c: Same. * symfile.c: Same. * symtab.h: Same. * target.c: Same. * tracepoint.c: Same. * tui/tui-data.h: Same. * tui/tui-io.c: Same. * tui/tui-win.c: Same. * tui/tui.c: Same. * unittests/rsp-low-selftests.c: Same. * user-regs.h: Same. * utils.c: Same. * utils.h: Same. * valarith.c: Same. * valops.c: Same. * valprint.c: Same. * valprint.h: Same. * value.c: Same. * value.h: Same. * varobj.c: Same. * x86-nat.h: Same. * xtensa-tdep.c: Same. gdb/gdbserver/ChangeLog: 2019-10-26 Tom de Vries <tdevries@suse.de> * linux-aarch64-low.c: Fix typos in comments. * linux-arm-low.c: Same. * linux-low.c: Same. * linux-ppc-low.c: Same. * proc-service.c: Same. * regcache.h: Same. * server.c: Same. * tracepoint.c: Same. * win32-low.c: Same. gdb/stubs/ChangeLog: 2019-10-26 Tom de Vries <tdevries@suse.de> * ia64vms-stub.c: Fix typos in comments. * m32r-stub.c: Same. * m68k-stub.c: Same. * sh-stub.c: Same. gdb/testsuite/ChangeLog: 2019-10-26 Tom de Vries <tdevries@suse.de> * gdb.base/bigcore.c: Fix typos in comments. * gdb.base/ctf-ptype.c: Same. * gdb.base/long_long.c: Same. * gdb.dwarf2/dw2-op-out-param.S: Same. * gdb.python/py-evthreads.c: Same. * gdb.reverse/i387-stack-reverse.c: Same. * gdb.trace/tfile.c: Same. * lib/compiler.c: Same. * lib/compiler.cc: Same. Change-Id: I8573d84a577894270179ae30f46c48d806fc1beb
2019-10-26 09:55:32 +02:00
the thread is stopped to successfully detach. Second, thread_db
may need to uninstall thread event breakpoints from memory, which
only works with a stopped process anyway. */
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
stop_all_lwps (0, NULL);
#ifdef USE_THREAD_DB
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
thread_db_detach (process);
#endif
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
/* Stabilize threads (move out of jump pads). */
target_stabilize_threads ();
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
Fix failure to detach if process exits while detaching on Linux This commit fixes detaching on Linux when some thread exits the whole thread group (process) just while we're detaching. On Linux, a ptracer must detach from each LWP individually, with PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if one of the already-detached threads causes the whole thread group to exit (e.g., simply calls exit), the kernel force-kills the other threads in the group, making them zombie, just as we're still detaching them. Since PTRACE_DETACH against a zombie thread fails with ESRCH, and gdb/gdbserver are not expecting this, the detach fails with an error like: "Can't detach process: No such process.". This patch detects this detach failure as normal, and instead of erroring out, reaps the now-dead thread. New test included, that exercises several different scenarios that cause GDB/GDBserver to error out when it should not. Tested on x86-64 GNU/Linux with {unix, native-gdbserver, native-extended-gdbserver} Note: without the previous fix, the "single-process + continue" variant of the new test would fail with: (gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent continue Continuing. Warning: Could not insert hardware watchpoint 3. Could not insert hardware breakpoints: You may have requested too many hardware breakpoints/watchpoints. Command aborted. (gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue gdb/gdbserver/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * linux-low.c: Change interface to take the target lwp_info pointer directly and return void. Handle detaching from a zombie thread. (linux_detach_lwp_callback): New function. (linux_detach): Detach from the leader thread after detaching from the clone threads. gdb/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * inf-ptrace.c (inf_ptrace_detach_success): New function, factored out from ... (inf_ptrace_detach): ... here. * inf-ptrace.h (inf_ptrace_detach_success): New declaration. * linux-nat.c (get_pending_status): Rename to ... (get_detach_signal): ... this, and return a host signal instead of filling in a wait status. (detach_one_lwp): New function, factored out from detach_callback and adjusted to handle detaching from a zombie thread. (detach_callback): Skip the leader thread. (linux_nat_detach): No longer defer to inf_ptrace_detach to detach the leader thread, nor build a signal string to pass down. Instead, use target_announce_detach, detach_one_lwp and inf_ptrace_detach_success. gdb/testsuite/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * gdb.threads/process-dies-while-detaching.c: New file. * gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
/* Detach from the clone lwps first. If the thread group exits just
while we're detaching, we must reap the clone lwps before we're
able to reap the leader. */
gdbserver/linux-low: turn process/thread addition/deletion ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'new_process', 'delete_process', 'new_thread', 'delete_thread', and 'new_fork' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <add_linux_process> <add_lwp> <delete_lwp> <attach_lwp> <detach_one_lwp> <check_zombie_leaders> <filter_exit_event> <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. * linux-low.cc (delete_lwp): Turn into... (linux_process_target::delete_lwp): ...this. (linux_process_target::low_delete_thread): Define. (linux_add_process): Turn into... (linux_process_target::add_linux_process): ...this. (linux_process_target::low_new_process): Define. (linux_process_target::low_delete_process): Define. (linux_process_target::low_new_fork): Define. (add_lwp): Turn into... (linux_process_target::add_lwp): ...this. (linux_process_target::low_new_thread): Define. (linux_attach_lwp): Turn into... (linux_process_target::attach_lwp): ...this. (linux_detach_one_lwp): Turn into... (linux_process_target::detach_one_lwp): ...this. (linux_detach_lwp_callback): Remove and inline... (linux_process_target::detach): ...here. (check_zombie_leaders): Turn into... (linux_process_target::check_zombie_leaders): ...this. (filter_exit_event): Turn into... (linux_process_target::filter_exit_event): ...this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::create_inferior) (attach_proc_task_lwp_callback) (linux_process_target::attach) (linux_process_target::detach) (linux_process_target::mourn) * thread-db.cc (attach_thread) * linux-x86-low.cc (class x86_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (x86_linux_new_process): Turn into... (x86_target::low_new_process): ...this. (x86_linux_delete_process): Turn into... (x86_target::low_delete_process): ...this. (x86_target::low_new_thread): Define. (x86_target::low_delete_thread): Define. (x86_linux_new_fork): Turn into... (x86_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (aarch64_linux_new_process): Turn into... (aarch64_target::low_new_process): ...this. (aarch64_linux_delete_process): Turn into... (aarch64_target::low_delete_process): ...this. (aarch64_target::low_new_thread): Define. (aarch64_target::low_delete_thread): Define. (aarch64_linux_new_fork): Turn into... (aarch64_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (arm_new_process): Turn into... (arm_target::low_new_process): ...this. (arm_delete_process): Turn into... (arm_target::low_delete_process): ...this. (arm_new_thread): Turn into... (arm_target::low_new_thread): ...this. (arm_delete_thread): Turn into... (arm_target::low_delete_thread): ...this. (arm_new_fork): Turn into... (arm_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (mips_linux_new_process): Turn into... (mips_target::low_new_process): ...this. (mips_linux_delete_process): Turn into... (mips_target::low_delete_process): ...this. (mips_linux_new_thread): Turn into... (mips_target::low_new_thread): ...this. (mips_linux_delete_thread): Turn into... (mips_target::low_delete_thread): ...this. (mips_linux_new_fork): Turn into... (mips_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:28 +02:00
for_each_thread (process->pid, [this] (thread_info *thread)
{
/* We don't actually detach from the thread group leader just yet.
If the thread group exits, we must reap the zombie clone lwps
before we're able to reap the leader. */
if (thread->id.pid () == thread->id.lwp ())
return;
lwp_info *lwp = get_thread_lwp (thread);
detach_one_lwp (lwp);
});
Fix failure to detach if process exits while detaching on Linux This commit fixes detaching on Linux when some thread exits the whole thread group (process) just while we're detaching. On Linux, a ptracer must detach from each LWP individually, with PTRACE_DETACH. Since PTRACE_DETACH sets the thread running free, if one of the already-detached threads causes the whole thread group to exit (e.g., simply calls exit), the kernel force-kills the other threads in the group, making them zombie, just as we're still detaching them. Since PTRACE_DETACH against a zombie thread fails with ESRCH, and gdb/gdbserver are not expecting this, the detach fails with an error like: "Can't detach process: No such process.". This patch detects this detach failure as normal, and instead of erroring out, reaps the now-dead thread. New test included, that exercises several different scenarios that cause GDB/GDBserver to error out when it should not. Tested on x86-64 GNU/Linux with {unix, native-gdbserver, native-extended-gdbserver} Note: without the previous fix, the "single-process + continue" variant of the new test would fail with: (gdb) PASS: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: switch to parent continue Continuing. Warning: Could not insert hardware watchpoint 3. Could not insert hardware breakpoints: You may have requested too many hardware breakpoints/watchpoints. Command aborted. (gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: watchpoint: continue gdb/gdbserver/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * linux-low.c: Change interface to take the target lwp_info pointer directly and return void. Handle detaching from a zombie thread. (linux_detach_lwp_callback): New function. (linux_detach): Detach from the leader thread after detaching from the clone threads. gdb/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * inf-ptrace.c (inf_ptrace_detach_success): New function, factored out from ... (inf_ptrace_detach): ... here. * inf-ptrace.h (inf_ptrace_detach_success): New declaration. * linux-nat.c (get_pending_status): Rename to ... (get_detach_signal): ... this, and return a host signal instead of filling in a wait status. (detach_one_lwp): New function, factored out from detach_callback and adjusted to handle detaching from a zombie thread. (detach_callback): Skip the leader thread. (linux_nat_detach): No longer defer to inf_ptrace_detach to detach the leader thread, nor build a signal string to pass down. Instead, use target_announce_detach, detach_one_lwp and inf_ptrace_detach_success. gdb/testsuite/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> Antoine Tremblay <antoine.tremblay@ericsson.com> * gdb.threads/process-dies-while-detaching.c: New file. * gdb.threads/process-dies-while-detaching.exp: New file.
2016-07-01 12:16:33 +02:00
main_lwp = find_lwp_pid (ptid_t (process->pid));
gdbserver/linux-low: turn process/thread addition/deletion ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'new_process', 'delete_process', 'new_thread', 'delete_thread', and 'new_fork' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <add_linux_process> <add_lwp> <delete_lwp> <attach_lwp> <detach_one_lwp> <check_zombie_leaders> <filter_exit_event> <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. * linux-low.cc (delete_lwp): Turn into... (linux_process_target::delete_lwp): ...this. (linux_process_target::low_delete_thread): Define. (linux_add_process): Turn into... (linux_process_target::add_linux_process): ...this. (linux_process_target::low_new_process): Define. (linux_process_target::low_delete_process): Define. (linux_process_target::low_new_fork): Define. (add_lwp): Turn into... (linux_process_target::add_lwp): ...this. (linux_process_target::low_new_thread): Define. (linux_attach_lwp): Turn into... (linux_process_target::attach_lwp): ...this. (linux_detach_one_lwp): Turn into... (linux_process_target::detach_one_lwp): ...this. (linux_detach_lwp_callback): Remove and inline... (linux_process_target::detach): ...here. (check_zombie_leaders): Turn into... (linux_process_target::check_zombie_leaders): ...this. (filter_exit_event): Turn into... (linux_process_target::filter_exit_event): ...this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::create_inferior) (attach_proc_task_lwp_callback) (linux_process_target::attach) (linux_process_target::detach) (linux_process_target::mourn) * thread-db.cc (attach_thread) * linux-x86-low.cc (class x86_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (x86_linux_new_process): Turn into... (x86_target::low_new_process): ...this. (x86_linux_delete_process): Turn into... (x86_target::low_delete_process): ...this. (x86_target::low_new_thread): Define. (x86_target::low_delete_thread): Define. (x86_linux_new_fork): Turn into... (x86_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (aarch64_linux_new_process): Turn into... (aarch64_target::low_new_process): ...this. (aarch64_linux_delete_process): Turn into... (aarch64_target::low_delete_process): ...this. (aarch64_target::low_new_thread): Define. (aarch64_target::low_delete_thread): Define. (aarch64_linux_new_fork): Turn into... (aarch64_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (arm_new_process): Turn into... (arm_target::low_new_process): ...this. (arm_delete_process): Turn into... (arm_target::low_delete_process): ...this. (arm_new_thread): Turn into... (arm_target::low_new_thread): ...this. (arm_delete_thread): Turn into... (arm_target::low_delete_thread): ...this. (arm_new_fork): Turn into... (arm_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (mips_linux_new_process): Turn into... (mips_target::low_new_process): ...this. (mips_linux_delete_process): Turn into... (mips_target::low_delete_process): ...this. (mips_linux_new_thread): Turn into... (mips_target::low_new_thread): ...this. (mips_linux_delete_thread): Turn into... (mips_target::low_delete_thread): ...this. (mips_linux_new_fork): Turn into... (mips_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:28 +02:00
detach_one_lwp (main_lwp);
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
mourn (process);
/* Since we presently can only stop all lwps of all processes, we
need to unstop lwps of other processes. */
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
unstop_all_lwps (0, NULL);
return 0;
}
/* Remove all LWPs that belong to process PROC from the lwp list. */
void
linux_process_target::mourn (process_info *process)
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
{
struct process_info_private *priv;
#ifdef USE_THREAD_DB
thread_db_mourn (process);
#endif
gdbserver/linux-low: turn process/thread addition/deletion ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'new_process', 'delete_process', 'new_thread', 'delete_thread', and 'new_fork' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <add_linux_process> <add_lwp> <delete_lwp> <attach_lwp> <detach_one_lwp> <check_zombie_leaders> <filter_exit_event> <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. * linux-low.cc (delete_lwp): Turn into... (linux_process_target::delete_lwp): ...this. (linux_process_target::low_delete_thread): Define. (linux_add_process): Turn into... (linux_process_target::add_linux_process): ...this. (linux_process_target::low_new_process): Define. (linux_process_target::low_delete_process): Define. (linux_process_target::low_new_fork): Define. (add_lwp): Turn into... (linux_process_target::add_lwp): ...this. (linux_process_target::low_new_thread): Define. (linux_attach_lwp): Turn into... (linux_process_target::attach_lwp): ...this. (linux_detach_one_lwp): Turn into... (linux_process_target::detach_one_lwp): ...this. (linux_detach_lwp_callback): Remove and inline... (linux_process_target::detach): ...here. (check_zombie_leaders): Turn into... (linux_process_target::check_zombie_leaders): ...this. (filter_exit_event): Turn into... (linux_process_target::filter_exit_event): ...this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::create_inferior) (attach_proc_task_lwp_callback) (linux_process_target::attach) (linux_process_target::detach) (linux_process_target::mourn) * thread-db.cc (attach_thread) * linux-x86-low.cc (class x86_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (x86_linux_new_process): Turn into... (x86_target::low_new_process): ...this. (x86_linux_delete_process): Turn into... (x86_target::low_delete_process): ...this. (x86_target::low_new_thread): Define. (x86_target::low_delete_thread): Define. (x86_linux_new_fork): Turn into... (x86_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (aarch64_linux_new_process): Turn into... (aarch64_target::low_new_process): ...this. (aarch64_linux_delete_process): Turn into... (aarch64_target::low_delete_process): ...this. (aarch64_target::low_new_thread): Define. (aarch64_target::low_delete_thread): Define. (aarch64_linux_new_fork): Turn into... (aarch64_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (arm_new_process): Turn into... (arm_target::low_new_process): ...this. (arm_delete_process): Turn into... (arm_target::low_delete_process): ...this. (arm_new_thread): Turn into... (arm_target::low_new_thread): ...this. (arm_delete_thread): Turn into... (arm_target::low_delete_thread): ...this. (arm_new_fork): Turn into... (arm_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (mips_linux_new_process): Turn into... (mips_target::low_new_process): ...this. (mips_linux_delete_process): Turn into... (mips_target::low_delete_process): ...this. (mips_linux_new_thread): Turn into... (mips_target::low_new_thread): ...this. (mips_linux_delete_thread): Turn into... (mips_target::low_delete_thread): ...this. (mips_linux_new_fork): Turn into... (mips_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:28 +02:00
for_each_thread (process->pid, [this] (thread_info *thread)
{
delete_lwp (get_thread_lwp (thread));
});
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
/* Freeing all private data. */
priv = process->priv;
gdbserver/linux-low: turn process/thread addition/deletion ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'new_process', 'delete_process', 'new_thread', 'delete_thread', and 'new_fork' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <add_linux_process> <add_lwp> <delete_lwp> <attach_lwp> <detach_one_lwp> <check_zombie_leaders> <filter_exit_event> <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. * linux-low.cc (delete_lwp): Turn into... (linux_process_target::delete_lwp): ...this. (linux_process_target::low_delete_thread): Define. (linux_add_process): Turn into... (linux_process_target::add_linux_process): ...this. (linux_process_target::low_new_process): Define. (linux_process_target::low_delete_process): Define. (linux_process_target::low_new_fork): Define. (add_lwp): Turn into... (linux_process_target::add_lwp): ...this. (linux_process_target::low_new_thread): Define. (linux_attach_lwp): Turn into... (linux_process_target::attach_lwp): ...this. (linux_detach_one_lwp): Turn into... (linux_process_target::detach_one_lwp): ...this. (linux_detach_lwp_callback): Remove and inline... (linux_process_target::detach): ...here. (check_zombie_leaders): Turn into... (linux_process_target::check_zombie_leaders): ...this. (filter_exit_event): Turn into... (linux_process_target::filter_exit_event): ...this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::create_inferior) (attach_proc_task_lwp_callback) (linux_process_target::attach) (linux_process_target::detach) (linux_process_target::mourn) * thread-db.cc (attach_thread) * linux-x86-low.cc (class x86_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (x86_linux_new_process): Turn into... (x86_target::low_new_process): ...this. (x86_linux_delete_process): Turn into... (x86_target::low_delete_process): ...this. (x86_target::low_new_thread): Define. (x86_target::low_delete_thread): Define. (x86_linux_new_fork): Turn into... (x86_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (aarch64_linux_new_process): Turn into... (aarch64_target::low_new_process): ...this. (aarch64_linux_delete_process): Turn into... (aarch64_target::low_delete_process): ...this. (aarch64_target::low_new_thread): Define. (aarch64_target::low_delete_thread): Define. (aarch64_linux_new_fork): Turn into... (aarch64_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (arm_new_process): Turn into... (arm_target::low_new_process): ...this. (arm_delete_process): Turn into... (arm_target::low_delete_process): ...this. (arm_new_thread): Turn into... (arm_target::low_new_thread): ...this. (arm_delete_thread): Turn into... (arm_target::low_delete_thread): ...this. (arm_new_fork): Turn into... (arm_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (mips_linux_new_process): Turn into... (mips_target::low_new_process): ...this. (mips_linux_delete_process): Turn into... (mips_target::low_delete_process): ...this. (mips_linux_new_thread): Turn into... (mips_target::low_new_thread): ...this. (mips_linux_delete_thread): Turn into... (mips_target::low_delete_thread): ...this. (mips_linux_new_fork): Turn into... (mips_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:28 +02:00
low_delete_process (priv->arch_private);
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
free (priv);
process->priv = NULL;
remove_process (process);
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
}
void
linux_process_target::join (int pid)
{
int status, ret;
do {
ret = my_waitpid (pid, &status, 0);
if (WIFEXITED (status) || WIFSIGNALED (status))
break;
} while (ret != -1 || errno != ECHILD);
}
/* Return true if the given thread is still alive. */
bool
linux_process_target::thread_alive (ptid_t ptid)
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
{
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
struct lwp_info *lwp = find_lwp_pid (ptid);
/* We assume we always know if a thread exits. If a whole process
exited but we still haven't been able to report it to GDB, we'll
hold on to the last lwp of the dead process. */
if (lwp != NULL)
Linux gdbserver confused when event randomization picks process exit event The tail end of linux_wait_1 isn't expecting that the select_event_lwp machinery can pick a whole-process exit event to report to GDB. When that happens, both gdb and gdbserver end up quite confused: ... (gdb) [Thread 24971.24971] #1 stopped. 0x0000003615a011f0 in ?? () c& Continuing. (gdb) [New Thread 24971.24981] [New Thread 24983.24983] [New Thread 24971.24982] [Thread 24983.24983] #3 stopped. 0x0000003615ebc7cc in __libc_fork () at ../nptl/sysdeps/unix/sysv/linux/fork.c:130 130 pid = ARCH_FORK (); [New Thread 24984.24984] Error in re-setting breakpoint -16: PC register is not available Error in re-setting breakpoint -17: PC register is not available Error in re-setting breakpoint -18: PC register is not available Error in re-setting breakpoint -19: PC register is not available Error in re-setting breakpoint -24: PC register is not available Error in re-setting breakpoint -25: PC register is not available Error in re-setting breakpoint -26: PC register is not available Error in re-setting breakpoint -27: PC register is not available Error in re-setting breakpoint -28: PC register is not available Error in re-setting breakpoint -29: PC register is not available Error in re-setting breakpoint -30: PC register is not available PC register is not available (gdb) gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (add_lwp): Set waitstatus to TARGET_WAITKIND_IGNORE. (linux_thread_alive): Use lwp_is_marked_dead. (extended_event_reported): Delete. (linux_wait_1): Check if waitstatus is TARGET_WAITKIND_IGNORE instead of extended_event_reported. (mark_lwp_dead): Don't set the 'dead' flag. Store the waitstatus as well. (lwp_is_marked_dead): New function. (lwp_running): Use lwp_is_marked_dead. * linux-low.h: Delete 'dead' field, and update 'waitstatus's comment.
2015-08-06 11:30:17 +02:00
return !lwp_is_marked_dead (lwp);
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
else
return 0;
}
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
bool
linux_process_target::thread_still_has_status_pending (thread_info *thread)
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
{
struct lwp_info *lp = get_thread_lwp (thread);
if (!lp->status_pending_p)
return 0;
if (thread->last_resume_kind != resume_stop
&& (lp->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT
|| lp->stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT))
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
{
struct thread_info *saved_thread;
CORE_ADDR pc;
int discard = 0;
gdb_assert (lp->last_status != 0);
pc = get_pc (lp);
saved_thread = current_thread;
current_thread = thread;
if (pc != lp->stop_pc)
{
if (debug_threads)
debug_printf ("PC of %ld changed\n",
lwpid_of (thread));
discard = 1;
}
#if !USE_SIGTRAP_SIGINFO
else if (lp->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT
gdbserver/linux-low: turn 'breakpoint_at' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'breakpoint_at' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <low_breakpoint_at>: Declare. Update the callers below: * linux-low.cc (linux_process_target::save_stop_reason) (linux_process_target::thread_still_has_status_pending) (linux_process_target::wait_1) * linux-x86-low.cc (class x86_target) <low_breakpoint_at>: Declare. (x86_breakpoint_at): Turn into... (x86_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <low_breakpoint_at>: Declare. (aarch64_breakpoint_at): Turn into... (aarch64_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (class arm_target) <low_breakpoint_at>: Declare. (arm_target::low_breakpoint_at): Define. (the_low_target): Remove the op field. * linux-bfin-low.cc (class bfin_target) <low_breakpoint_at>: Declare. (bfin_breakpoint_at): Turn into... (bfin_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-cris-low.cc (class cris_target) <low_breakpoint_at>: Declare. (cris_breakpoint_at): Turn into... (cris_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-crisv32-low.cc (class crisv32_target) <low_breakpoint_at>: Declare. (crisv32_breakpoint_at): Turn into... (crisv32_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-ia64-low.cc (class ia64_target) <low_breakpoint_at>: Declare. (ia64_target::low_breakpoint_at): Define. * linux-m32r-low.cc (class m32r_target) <low_breakpoint_at>: Declare. (m32r_breakpoint_at): Turn into... (m32r_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-m68k-low.cc (class m68k_target) <low_breakpoint_at>: Declare. (m68k_breakpoint_at): Turn into... (m68k_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-mips-low.cc (class mips_target) <low_breakpoint_at>: Declare. (mips_breakpoint_at): Turn into... (mips_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-nios2-low.cc (class nios2_target) <low_breakpoint_at>: Declare. (nios2_breakpoint_at): Turn into... (nios2_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (class ppc_target) <low_breakpoint_at>: Declare. (ppc_breakpoint_at): Turn into... (ppc_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-riscv-low.cc (class riscv_target) <low_breakpoint_at>: Declare. (riscv_breakpoint_at): Turn into... (riscv_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-s390-low.cc (class s390_target) <low_breakpoint_at>: Declare. (s390_breakpoint_at): Turn into... (s390_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-sh-low.cc (class sh_target) <low_breakpoint_at>: Declare. (sh_breakpoint_at): Turn into... (sh_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-sparc-low.cc (class sparc_target) <low_breakpoint_at>: Declare. (sparc_breakpoint_at): Turn into... (sparc_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-tic6x-low.cc (class tic6x_target) <low_breakpoint_at>: Declare. (tic6x_breakpoint_at): Turn into... (tic6x_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-tile-low.cc (class tile_target) <low_breakpoint_at>: Declare. (tile_breakpoint_at): Turn into... (tile_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-xtensa-low.cc (class xtensa_target) <low_breakpoint_at>: Declare. (xtensa_breakpoint_at): Turn into... (xtensa_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field.
2020-04-02 15:11:26 +02:00
&& !low_breakpoint_at (pc))
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
{
if (debug_threads)
debug_printf ("previous SW breakpoint of %ld gone\n",
lwpid_of (thread));
discard = 1;
}
else if (lp->stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
&& !hardware_breakpoint_inserted_here (pc))
{
if (debug_threads)
debug_printf ("previous HW breakpoint of %ld gone\n",
lwpid_of (thread));
discard = 1;
}
#endif
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
current_thread = saved_thread;
if (discard)
{
if (debug_threads)
debug_printf ("discarding pending breakpoint status\n");
lp->status_pending_p = 0;
return 0;
}
}
return 1;
}
gdbserver: fix killed-outside.exp killed-outside.exp regresses with "maint set target-non-stop on". The logs show: (gdb) continue Continuing. infrun: clear_proceed_status_thread (Thread 9028.9028) infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT) infrun: proceed: resuming Thread 9028.9028 Sending packet: $Z0,3615a03966,1#4b... Notification received: Stop:X9;process:2344 Packet received: E01 Sending packet: $Z0,3615a13970,1#47...Packet received: E01 Sending packet: $Z0,3615a14891,1#4a...Packet received: E01 infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [Thread 9028.9028] at 0x4005e4 Sending packet: $vCont;c:p2344.2344#1a...Packet received: E.target not running. Sending packet: $qXfer:threads:read::0,fff#03...Packet received: l<threads>\n</threads>\n Sending packet: $vStopped#55...Packet received: OK Unexpected vCont reply in non-stop mode: E.target not running. (gdb) remote_async_inferior_event_handler infrun: target_wait (-1.0.0, status) = infrun: 9028.0.0 [process 9028], infrun: status->kind = signalled, signal = GDB_SIGNAL_KILL infrun: TARGET_WAITKIND_SIGNALLED Program terminated with signal SIGKILL, Killed. The program no longer exists. infrun: stop_waiting infrun: clear_step_over_info infrun: stop_all_threads remote_thread_exit_events(1) Note the "Unexpected vCont reply" error. I traced it to a problem in status_pending_p_callback. It resumes an LWP when it shouldn't. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * linux-low.c (thread_still_has_status_pending_p): Don't check vCont;t here. (lwp_resumed): New function. (status_pending_p_callback): Return early if the LWP is not supposed to be resumed.
2015-11-30 17:05:23 +01:00
/* Returns true if LWP is resumed from the client's perspective. */
static int
lwp_resumed (struct lwp_info *lwp)
{
struct thread_info *thread = get_lwp_thread (lwp);
if (thread->last_resume_kind != resume_stop)
return 1;
/* Did gdb send us a `vCont;t', but we haven't reported the
corresponding stop to gdb yet? If so, the thread is still
resumed/running from gdb's perspective. */
if (thread->last_resume_kind == resume_stop
&& thread->last_status.kind == TARGET_WAITKIND_IGNORE)
return 1;
return 0;
}
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
bool
linux_process_target::status_pending_p_callback (thread_info *thread,
ptid_t ptid)
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
{
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
struct lwp_info *lp = get_thread_lwp (thread);
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
/* Check if we're only interested in events from a specific process
or a specific LWP. */
if (!thread->id.matches (ptid))
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
return 0;
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
gdbserver: fix killed-outside.exp killed-outside.exp regresses with "maint set target-non-stop on". The logs show: (gdb) continue Continuing. infrun: clear_proceed_status_thread (Thread 9028.9028) infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT) infrun: proceed: resuming Thread 9028.9028 Sending packet: $Z0,3615a03966,1#4b... Notification received: Stop:X9;process:2344 Packet received: E01 Sending packet: $Z0,3615a13970,1#47...Packet received: E01 Sending packet: $Z0,3615a14891,1#4a...Packet received: E01 infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [Thread 9028.9028] at 0x4005e4 Sending packet: $vCont;c:p2344.2344#1a...Packet received: E.target not running. Sending packet: $qXfer:threads:read::0,fff#03...Packet received: l<threads>\n</threads>\n Sending packet: $vStopped#55...Packet received: OK Unexpected vCont reply in non-stop mode: E.target not running. (gdb) remote_async_inferior_event_handler infrun: target_wait (-1.0.0, status) = infrun: 9028.0.0 [process 9028], infrun: status->kind = signalled, signal = GDB_SIGNAL_KILL infrun: TARGET_WAITKIND_SIGNALLED Program terminated with signal SIGKILL, Killed. The program no longer exists. infrun: stop_waiting infrun: clear_step_over_info infrun: stop_all_threads remote_thread_exit_events(1) Note the "Unexpected vCont reply" error. I traced it to a problem in status_pending_p_callback. It resumes an LWP when it shouldn't. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * linux-low.c (thread_still_has_status_pending_p): Don't check vCont;t here. (lwp_resumed): New function. (status_pending_p_callback): Return early if the LWP is not supposed to be resumed.
2015-11-30 17:05:23 +01:00
if (!lwp_resumed (lp))
return 0;
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
if (lp->status_pending_p
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
&& !thread_still_has_status_pending (thread))
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
{
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
resume_one_lwp (lp, lp->stepping, GDB_SIGNAL_0, NULL);
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
return 0;
}
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
return lp->status_pending_p;
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
}
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
struct lwp_info *
find_lwp_pid (ptid_t ptid)
{
thread_info *thread = find_thread ([&] (thread_info *thr_arg)
{
int lwp = ptid.lwp () != 0 ? ptid.lwp () : ptid.pid ();
return thr_arg->id.lwp () == lwp;
});
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
if (thread == NULL)
return NULL;
gdbserver: use std::list for all_threads Remove the usage of inferior_list for the all_threads list in gdbserver. The entry field in thread_info is removed, and replaced by a simple ptid field. I added some functions to iterate (for_each_thread) and find threads (find_thread). However, changing all the users of find_inferior & co to use these new functions would have made the patch way too big. So I opted instead to make find_inferior & co some shims, so that the existing code only needs to be updated minimally. We can then update the existing code to use the new functions incrementally (I've started to do the work, but I'll post it afterwards, see [1] if you want a peek). This patch has been built-tested on all relevant platforms, except lynx. I also regtested using the native-gdbserver and native-extended-gdbserver boards on x86. [1] https://github.com/simark/binutils-gdb/commits/kill-inferior-list-entry gdb/gdbserver/ChangeLog: * inferiors.h: (struct inferior_list): Remove. (struct inferior_list_entry); Remove. (add_inferior_to_list, clear_inferior_list, one_inferior_p, A_I_NEXT, ALL_INFERIORS_TYPE, ALL_INFERIORS, remove_inferior, get_first_inferior): Remove. (for_each_inferior, for_each_inferior_with_data, find_inferior, find_inferior_id, find_inferior_in_random): Change signature. * inferiors.c (all_threads): Change type to std::list<thread_info *>. (get_thread): Remove macro. (find_inferior, find_inferior_id): Change signature, implement using find_thread. (find_inferior_in_random): Change signature, implement using find_thread_in_random. (for_each_inferior, for_each_inferior_with_data): Change signature, implement using for_each_thread. (add_inferior_to_list, remove_inferior): Remove. (add_thread, get_first_thread, thread_of_pid, find_any_thread_of_pid, free_one_thread, remove_thread): Update. (get_first_inferior, one_inferior_p, clear_inferior_list): Remove. (clear_inferiors, get_thread_process): Update. * gdbthread.h: Include <list>. (struct thread_info) <entry>: Remove field. <id>: New field. (all_threads): Change type to std::list<thread_info *>. (get_first_inferior): Add doc. (find_thread, for_each_thread, find_thread_in_random): New functions. (current_ptid, pid_of, ptid_of, lwpid_of): Update. * linux-arm-low.c (update_registers_callback): Update. * linux-low.c (second_thread_of_pid_p): Update. (kill_one_lwp_callback, linux_detach_lwp_callback, delete_lwp_callback, status_pending_p_callback, same_lwp, find_lwp_pid, num_lwps, iterate_over_lwps_filter, iterate_over_lwps, not_stopped_callback, resume_stopped_resumed_lwps, count_events_callback, select_singlestep_lwp_callback, select_event_lwp_callback, unsuspend_one_lwp, linux_wait_1, send_sigstop_callback, suspend_and_send_sigstop_callback, wait_for_sigstop, stuck_in_jump_pad_callback, move_out_of_jump_pad_callback, lwp_running, linux_set_resume_request, resume_status_pending_p, need_step_over_p, start_step_over, linux_resume_one_thread, proceed_one_lwp, unsuspend_and_proceed_one_lwp, reset_lwp_ptrace_options_callback): Update. * linux-mips-low.c (update_watch_registers_callback): Update. * regcache.c (regcache_invalidate_one, regcache_invalidate): Update. (free_register_cache_thread_one): Remove. (regcache_release): Update. * server.c (handle_btrace_enable_bts, handle_btrace_enable_pt, handle_qxfer_threads_worker): Update. (handle_query): Update, use list iterator. (visit_actioned_threads, handle_pending_status, queue_stop_reply_callback, gdb_wants_all_threads_stopped, clear_pending_status_callback, set_pending_status_callback, find_status_pending_thread_callback, handle_status, process_serial_event): Update. * target.c (thread_search_callback): Update. * thread-db.c (thread_db_get_tls_address): Update. * tracepoint.c (tracepoint_finished_step, tracepoint_was_hit): Update. * win32-i386-low.c (update_debug_registers_callback): Update. * win32-low.c (delete_thread_info, child_delete_thread, continue_one_thread, suspend_one_thread, get_child_debug_event): Adjust.
2017-10-14 15:11:12 +02:00
return get_thread_lwp (thread);
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
}
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
/* Return the number of known LWPs in the tgid given by PID. */
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
static int
num_lwps (int pid)
{
int count = 0;
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
for_each_thread (pid, [&] (thread_info *thread)
{
gdbserver: use std::list for all_threads Remove the usage of inferior_list for the all_threads list in gdbserver. The entry field in thread_info is removed, and replaced by a simple ptid field. I added some functions to iterate (for_each_thread) and find threads (find_thread). However, changing all the users of find_inferior & co to use these new functions would have made the patch way too big. So I opted instead to make find_inferior & co some shims, so that the existing code only needs to be updated minimally. We can then update the existing code to use the new functions incrementally (I've started to do the work, but I'll post it afterwards, see [1] if you want a peek). This patch has been built-tested on all relevant platforms, except lynx. I also regtested using the native-gdbserver and native-extended-gdbserver boards on x86. [1] https://github.com/simark/binutils-gdb/commits/kill-inferior-list-entry gdb/gdbserver/ChangeLog: * inferiors.h: (struct inferior_list): Remove. (struct inferior_list_entry); Remove. (add_inferior_to_list, clear_inferior_list, one_inferior_p, A_I_NEXT, ALL_INFERIORS_TYPE, ALL_INFERIORS, remove_inferior, get_first_inferior): Remove. (for_each_inferior, for_each_inferior_with_data, find_inferior, find_inferior_id, find_inferior_in_random): Change signature. * inferiors.c (all_threads): Change type to std::list<thread_info *>. (get_thread): Remove macro. (find_inferior, find_inferior_id): Change signature, implement using find_thread. (find_inferior_in_random): Change signature, implement using find_thread_in_random. (for_each_inferior, for_each_inferior_with_data): Change signature, implement using for_each_thread. (add_inferior_to_list, remove_inferior): Remove. (add_thread, get_first_thread, thread_of_pid, find_any_thread_of_pid, free_one_thread, remove_thread): Update. (get_first_inferior, one_inferior_p, clear_inferior_list): Remove. (clear_inferiors, get_thread_process): Update. * gdbthread.h: Include <list>. (struct thread_info) <entry>: Remove field. <id>: New field. (all_threads): Change type to std::list<thread_info *>. (get_first_inferior): Add doc. (find_thread, for_each_thread, find_thread_in_random): New functions. (current_ptid, pid_of, ptid_of, lwpid_of): Update. * linux-arm-low.c (update_registers_callback): Update. * linux-low.c (second_thread_of_pid_p): Update. (kill_one_lwp_callback, linux_detach_lwp_callback, delete_lwp_callback, status_pending_p_callback, same_lwp, find_lwp_pid, num_lwps, iterate_over_lwps_filter, iterate_over_lwps, not_stopped_callback, resume_stopped_resumed_lwps, count_events_callback, select_singlestep_lwp_callback, select_event_lwp_callback, unsuspend_one_lwp, linux_wait_1, send_sigstop_callback, suspend_and_send_sigstop_callback, wait_for_sigstop, stuck_in_jump_pad_callback, move_out_of_jump_pad_callback, lwp_running, linux_set_resume_request, resume_status_pending_p, need_step_over_p, start_step_over, linux_resume_one_thread, proceed_one_lwp, unsuspend_and_proceed_one_lwp, reset_lwp_ptrace_options_callback): Update. * linux-mips-low.c (update_watch_registers_callback): Update. * regcache.c (regcache_invalidate_one, regcache_invalidate): Update. (free_register_cache_thread_one): Remove. (regcache_release): Update. * server.c (handle_btrace_enable_bts, handle_btrace_enable_pt, handle_qxfer_threads_worker): Update. (handle_query): Update, use list iterator. (visit_actioned_threads, handle_pending_status, queue_stop_reply_callback, gdb_wants_all_threads_stopped, clear_pending_status_callback, set_pending_status_callback, find_status_pending_thread_callback, handle_status, process_serial_event): Update. * target.c (thread_search_callback): Update. * thread-db.c (thread_db_get_tls_address): Update. * tracepoint.c (tracepoint_finished_step, tracepoint_was_hit): Update. * win32-i386-low.c (update_debug_registers_callback): Update. * win32-low.c (delete_thread_info, child_delete_thread, continue_one_thread, suspend_one_thread, get_child_debug_event): Adjust.
2017-10-14 15:11:12 +02:00
count++;
});
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
return count;
}
/* See nat/linux-nat.h. */
struct lwp_info *
iterate_over_lwps (ptid_t filter,
Change iterate_over_lwps to take a gdb::function_view This changes iterate_over_lwps to use a gdb::function_view. This was needed in order to make null_ptid and minus_one_ptid 'const'. gdb/ChangeLog 2019-03-12 Tom Tromey <tromey@adacore.com> * linux-nat.c (iterate_over_lwps): Update. (stop_callback): Remove parameter. (stop_wait_callback, detach_callback, resume_set_callback) (select_singlestep_lwp_callback, set_ignore_sigint) (status_callback, resumed_callback, resume_clear_callback) (kill_callback, kill_wait_callback, linux_nat_stop_lwp): Remove data parameter. (linux_nat_target::detach, linux_nat_target::resume) (linux_stop_and_wait_all_lwps, select_event_lwp) (linux_nat_filter_event, linux_nat_wait_1) (linux_nat_target::kill, linux_nat_target::stop) (linux_nat_target::stop): Update. (linux_nat_resume_callback): Change type. (resume_stopped_resumed_lwps, count_events_callback) (select_event_lwp_callback): Likewise. (linux_stop_lwp, linux_nat_stop_lwp): Update. * arm-linux-nat.c (struct update_registers_data): Remove. (update_registers_callback): Change type. (arm_linux_insert_hw_breakpoint1): Update. * nat/x86-linux-dregs.c (update_debug_registers_callback): Remove parameter. (x86_linux_dr_set_addr): Update. (x86_linux_dr_set_control): Update. * nat/linux-nat.h (iterate_over_lwps_ftype): Remove parameter. (iterate_over_lwps): Use gdb::function_view. * nat/aarch64-linux-hw-point.c (struct aarch64_dr_update_callback_param): Remove. (debug_reg_change_callback): Change type. (aarch64_notify_debug_reg_change): Update. * s390-linux-nat.c (s390_refresh_per_info): Update. gdb/gdbserver/ChangeLog 2019-03-12 Tom Tromey <tromey@adacore.com> * linux-low.c (iterate_over_lwps): Update.
2019-03-04 20:05:03 +01:00
gdb::function_view<iterate_over_lwps_ftype> callback)
{
thread_info *thread = find_thread (filter, [&] (thread_info *thr_arg)
{
lwp_info *lwp = get_thread_lwp (thr_arg);
Change iterate_over_lwps to take a gdb::function_view This changes iterate_over_lwps to use a gdb::function_view. This was needed in order to make null_ptid and minus_one_ptid 'const'. gdb/ChangeLog 2019-03-12 Tom Tromey <tromey@adacore.com> * linux-nat.c (iterate_over_lwps): Update. (stop_callback): Remove parameter. (stop_wait_callback, detach_callback, resume_set_callback) (select_singlestep_lwp_callback, set_ignore_sigint) (status_callback, resumed_callback, resume_clear_callback) (kill_callback, kill_wait_callback, linux_nat_stop_lwp): Remove data parameter. (linux_nat_target::detach, linux_nat_target::resume) (linux_stop_and_wait_all_lwps, select_event_lwp) (linux_nat_filter_event, linux_nat_wait_1) (linux_nat_target::kill, linux_nat_target::stop) (linux_nat_target::stop): Update. (linux_nat_resume_callback): Change type. (resume_stopped_resumed_lwps, count_events_callback) (select_event_lwp_callback): Likewise. (linux_stop_lwp, linux_nat_stop_lwp): Update. * arm-linux-nat.c (struct update_registers_data): Remove. (update_registers_callback): Change type. (arm_linux_insert_hw_breakpoint1): Update. * nat/x86-linux-dregs.c (update_debug_registers_callback): Remove parameter. (x86_linux_dr_set_addr): Update. (x86_linux_dr_set_control): Update. * nat/linux-nat.h (iterate_over_lwps_ftype): Remove parameter. (iterate_over_lwps): Use gdb::function_view. * nat/aarch64-linux-hw-point.c (struct aarch64_dr_update_callback_param): Remove. (debug_reg_change_callback): Change type. (aarch64_notify_debug_reg_change): Update. * s390-linux-nat.c (s390_refresh_per_info): Update. gdb/gdbserver/ChangeLog 2019-03-12 Tom Tromey <tromey@adacore.com> * linux-low.c (iterate_over_lwps): Update.
2019-03-04 20:05:03 +01:00
return callback (lwp);
});
gdbserver: use std::list for all_threads Remove the usage of inferior_list for the all_threads list in gdbserver. The entry field in thread_info is removed, and replaced by a simple ptid field. I added some functions to iterate (for_each_thread) and find threads (find_thread). However, changing all the users of find_inferior & co to use these new functions would have made the patch way too big. So I opted instead to make find_inferior & co some shims, so that the existing code only needs to be updated minimally. We can then update the existing code to use the new functions incrementally (I've started to do the work, but I'll post it afterwards, see [1] if you want a peek). This patch has been built-tested on all relevant platforms, except lynx. I also regtested using the native-gdbserver and native-extended-gdbserver boards on x86. [1] https://github.com/simark/binutils-gdb/commits/kill-inferior-list-entry gdb/gdbserver/ChangeLog: * inferiors.h: (struct inferior_list): Remove. (struct inferior_list_entry); Remove. (add_inferior_to_list, clear_inferior_list, one_inferior_p, A_I_NEXT, ALL_INFERIORS_TYPE, ALL_INFERIORS, remove_inferior, get_first_inferior): Remove. (for_each_inferior, for_each_inferior_with_data, find_inferior, find_inferior_id, find_inferior_in_random): Change signature. * inferiors.c (all_threads): Change type to std::list<thread_info *>. (get_thread): Remove macro. (find_inferior, find_inferior_id): Change signature, implement using find_thread. (find_inferior_in_random): Change signature, implement using find_thread_in_random. (for_each_inferior, for_each_inferior_with_data): Change signature, implement using for_each_thread. (add_inferior_to_list, remove_inferior): Remove. (add_thread, get_first_thread, thread_of_pid, find_any_thread_of_pid, free_one_thread, remove_thread): Update. (get_first_inferior, one_inferior_p, clear_inferior_list): Remove. (clear_inferiors, get_thread_process): Update. * gdbthread.h: Include <list>. (struct thread_info) <entry>: Remove field. <id>: New field. (all_threads): Change type to std::list<thread_info *>. (get_first_inferior): Add doc. (find_thread, for_each_thread, find_thread_in_random): New functions. (current_ptid, pid_of, ptid_of, lwpid_of): Update. * linux-arm-low.c (update_registers_callback): Update. * linux-low.c (second_thread_of_pid_p): Update. (kill_one_lwp_callback, linux_detach_lwp_callback, delete_lwp_callback, status_pending_p_callback, same_lwp, find_lwp_pid, num_lwps, iterate_over_lwps_filter, iterate_over_lwps, not_stopped_callback, resume_stopped_resumed_lwps, count_events_callback, select_singlestep_lwp_callback, select_event_lwp_callback, unsuspend_one_lwp, linux_wait_1, send_sigstop_callback, suspend_and_send_sigstop_callback, wait_for_sigstop, stuck_in_jump_pad_callback, move_out_of_jump_pad_callback, lwp_running, linux_set_resume_request, resume_status_pending_p, need_step_over_p, start_step_over, linux_resume_one_thread, proceed_one_lwp, unsuspend_and_proceed_one_lwp, reset_lwp_ptrace_options_callback): Update. * linux-mips-low.c (update_watch_registers_callback): Update. * regcache.c (regcache_invalidate_one, regcache_invalidate): Update. (free_register_cache_thread_one): Remove. (regcache_release): Update. * server.c (handle_btrace_enable_bts, handle_btrace_enable_pt, handle_qxfer_threads_worker): Update. (handle_query): Update, use list iterator. (visit_actioned_threads, handle_pending_status, queue_stop_reply_callback, gdb_wants_all_threads_stopped, clear_pending_status_callback, set_pending_status_callback, find_status_pending_thread_callback, handle_status, process_serial_event): Update. * target.c (thread_search_callback): Update. * thread-db.c (thread_db_get_tls_address): Update. * tracepoint.c (tracepoint_finished_step, tracepoint_was_hit): Update. * win32-i386-low.c (update_debug_registers_callback): Update. * win32-low.c (delete_thread_info, child_delete_thread, continue_one_thread, suspend_one_thread, get_child_debug_event): Adjust.
2017-10-14 15:11:12 +02:00
if (thread == NULL)
return NULL;
gdbserver: use std::list for all_threads Remove the usage of inferior_list for the all_threads list in gdbserver. The entry field in thread_info is removed, and replaced by a simple ptid field. I added some functions to iterate (for_each_thread) and find threads (find_thread). However, changing all the users of find_inferior & co to use these new functions would have made the patch way too big. So I opted instead to make find_inferior & co some shims, so that the existing code only needs to be updated minimally. We can then update the existing code to use the new functions incrementally (I've started to do the work, but I'll post it afterwards, see [1] if you want a peek). This patch has been built-tested on all relevant platforms, except lynx. I also regtested using the native-gdbserver and native-extended-gdbserver boards on x86. [1] https://github.com/simark/binutils-gdb/commits/kill-inferior-list-entry gdb/gdbserver/ChangeLog: * inferiors.h: (struct inferior_list): Remove. (struct inferior_list_entry); Remove. (add_inferior_to_list, clear_inferior_list, one_inferior_p, A_I_NEXT, ALL_INFERIORS_TYPE, ALL_INFERIORS, remove_inferior, get_first_inferior): Remove. (for_each_inferior, for_each_inferior_with_data, find_inferior, find_inferior_id, find_inferior_in_random): Change signature. * inferiors.c (all_threads): Change type to std::list<thread_info *>. (get_thread): Remove macro. (find_inferior, find_inferior_id): Change signature, implement using find_thread. (find_inferior_in_random): Change signature, implement using find_thread_in_random. (for_each_inferior, for_each_inferior_with_data): Change signature, implement using for_each_thread. (add_inferior_to_list, remove_inferior): Remove. (add_thread, get_first_thread, thread_of_pid, find_any_thread_of_pid, free_one_thread, remove_thread): Update. (get_first_inferior, one_inferior_p, clear_inferior_list): Remove. (clear_inferiors, get_thread_process): Update. * gdbthread.h: Include <list>. (struct thread_info) <entry>: Remove field. <id>: New field. (all_threads): Change type to std::list<thread_info *>. (get_first_inferior): Add doc. (find_thread, for_each_thread, find_thread_in_random): New functions. (current_ptid, pid_of, ptid_of, lwpid_of): Update. * linux-arm-low.c (update_registers_callback): Update. * linux-low.c (second_thread_of_pid_p): Update. (kill_one_lwp_callback, linux_detach_lwp_callback, delete_lwp_callback, status_pending_p_callback, same_lwp, find_lwp_pid, num_lwps, iterate_over_lwps_filter, iterate_over_lwps, not_stopped_callback, resume_stopped_resumed_lwps, count_events_callback, select_singlestep_lwp_callback, select_event_lwp_callback, unsuspend_one_lwp, linux_wait_1, send_sigstop_callback, suspend_and_send_sigstop_callback, wait_for_sigstop, stuck_in_jump_pad_callback, move_out_of_jump_pad_callback, lwp_running, linux_set_resume_request, resume_status_pending_p, need_step_over_p, start_step_over, linux_resume_one_thread, proceed_one_lwp, unsuspend_and_proceed_one_lwp, reset_lwp_ptrace_options_callback): Update. * linux-mips-low.c (update_watch_registers_callback): Update. * regcache.c (regcache_invalidate_one, regcache_invalidate): Update. (free_register_cache_thread_one): Remove. (regcache_release): Update. * server.c (handle_btrace_enable_bts, handle_btrace_enable_pt, handle_qxfer_threads_worker): Update. (handle_query): Update, use list iterator. (visit_actioned_threads, handle_pending_status, queue_stop_reply_callback, gdb_wants_all_threads_stopped, clear_pending_status_callback, set_pending_status_callback, find_status_pending_thread_callback, handle_status, process_serial_event): Update. * target.c (thread_search_callback): Update. * thread-db.c (thread_db_get_tls_address): Update. * tracepoint.c (tracepoint_finished_step, tracepoint_was_hit): Update. * win32-i386-low.c (update_debug_registers_callback): Update. * win32-low.c (delete_thread_info, child_delete_thread, continue_one_thread, suspend_one_thread, get_child_debug_event): Adjust.
2017-10-14 15:11:12 +02:00
return get_thread_lwp (thread);
}
gdbserver/linux-low: turn process/thread addition/deletion ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'new_process', 'delete_process', 'new_thread', 'delete_thread', and 'new_fork' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <add_linux_process> <add_lwp> <delete_lwp> <attach_lwp> <detach_one_lwp> <check_zombie_leaders> <filter_exit_event> <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. * linux-low.cc (delete_lwp): Turn into... (linux_process_target::delete_lwp): ...this. (linux_process_target::low_delete_thread): Define. (linux_add_process): Turn into... (linux_process_target::add_linux_process): ...this. (linux_process_target::low_new_process): Define. (linux_process_target::low_delete_process): Define. (linux_process_target::low_new_fork): Define. (add_lwp): Turn into... (linux_process_target::add_lwp): ...this. (linux_process_target::low_new_thread): Define. (linux_attach_lwp): Turn into... (linux_process_target::attach_lwp): ...this. (linux_detach_one_lwp): Turn into... (linux_process_target::detach_one_lwp): ...this. (linux_detach_lwp_callback): Remove and inline... (linux_process_target::detach): ...here. (check_zombie_leaders): Turn into... (linux_process_target::check_zombie_leaders): ...this. (filter_exit_event): Turn into... (linux_process_target::filter_exit_event): ...this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::create_inferior) (attach_proc_task_lwp_callback) (linux_process_target::attach) (linux_process_target::detach) (linux_process_target::mourn) * thread-db.cc (attach_thread) * linux-x86-low.cc (class x86_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (x86_linux_new_process): Turn into... (x86_target::low_new_process): ...this. (x86_linux_delete_process): Turn into... (x86_target::low_delete_process): ...this. (x86_target::low_new_thread): Define. (x86_target::low_delete_thread): Define. (x86_linux_new_fork): Turn into... (x86_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (aarch64_linux_new_process): Turn into... (aarch64_target::low_new_process): ...this. (aarch64_linux_delete_process): Turn into... (aarch64_target::low_delete_process): ...this. (aarch64_target::low_new_thread): Define. (aarch64_target::low_delete_thread): Define. (aarch64_linux_new_fork): Turn into... (aarch64_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (arm_new_process): Turn into... (arm_target::low_new_process): ...this. (arm_delete_process): Turn into... (arm_target::low_delete_process): ...this. (arm_new_thread): Turn into... (arm_target::low_new_thread): ...this. (arm_delete_thread): Turn into... (arm_target::low_delete_thread): ...this. (arm_new_fork): Turn into... (arm_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (mips_linux_new_process): Turn into... (mips_target::low_new_process): ...this. (mips_linux_delete_process): Turn into... (mips_target::low_delete_process): ...this. (mips_linux_new_thread): Turn into... (mips_target::low_new_thread): ...this. (mips_linux_delete_thread): Turn into... (mips_target::low_delete_thread): ...this. (mips_linux_new_fork): Turn into... (mips_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:28 +02:00
void
linux_process_target::check_zombie_leaders ()
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
{
gdbserver/linux-low: turn process/thread addition/deletion ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'new_process', 'delete_process', 'new_thread', 'delete_thread', and 'new_fork' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <add_linux_process> <add_lwp> <delete_lwp> <attach_lwp> <detach_one_lwp> <check_zombie_leaders> <filter_exit_event> <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. * linux-low.cc (delete_lwp): Turn into... (linux_process_target::delete_lwp): ...this. (linux_process_target::low_delete_thread): Define. (linux_add_process): Turn into... (linux_process_target::add_linux_process): ...this. (linux_process_target::low_new_process): Define. (linux_process_target::low_delete_process): Define. (linux_process_target::low_new_fork): Define. (add_lwp): Turn into... (linux_process_target::add_lwp): ...this. (linux_process_target::low_new_thread): Define. (linux_attach_lwp): Turn into... (linux_process_target::attach_lwp): ...this. (linux_detach_one_lwp): Turn into... (linux_process_target::detach_one_lwp): ...this. (linux_detach_lwp_callback): Remove and inline... (linux_process_target::detach): ...here. (check_zombie_leaders): Turn into... (linux_process_target::check_zombie_leaders): ...this. (filter_exit_event): Turn into... (linux_process_target::filter_exit_event): ...this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::create_inferior) (attach_proc_task_lwp_callback) (linux_process_target::attach) (linux_process_target::detach) (linux_process_target::mourn) * thread-db.cc (attach_thread) * linux-x86-low.cc (class x86_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (x86_linux_new_process): Turn into... (x86_target::low_new_process): ...this. (x86_linux_delete_process): Turn into... (x86_target::low_delete_process): ...this. (x86_target::low_new_thread): Define. (x86_target::low_delete_thread): Define. (x86_linux_new_fork): Turn into... (x86_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (aarch64_linux_new_process): Turn into... (aarch64_target::low_new_process): ...this. (aarch64_linux_delete_process): Turn into... (aarch64_target::low_delete_process): ...this. (aarch64_target::low_new_thread): Define. (aarch64_target::low_delete_thread): Define. (aarch64_linux_new_fork): Turn into... (aarch64_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (arm_new_process): Turn into... (arm_target::low_new_process): ...this. (arm_delete_process): Turn into... (arm_target::low_delete_process): ...this. (arm_new_thread): Turn into... (arm_target::low_new_thread): ...this. (arm_delete_thread): Turn into... (arm_target::low_delete_thread): ...this. (arm_new_fork): Turn into... (arm_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (mips_linux_new_process): Turn into... (mips_target::low_new_process): ...this. (mips_linux_delete_process): Turn into... (mips_target::low_delete_process): ...this. (mips_linux_new_thread): Turn into... (mips_target::low_new_thread): ...this. (mips_linux_delete_thread): Turn into... (mips_target::low_delete_thread): ...this. (mips_linux_new_fork): Turn into... (mips_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:28 +02:00
for_each_process ([this] (process_info *proc) {
gdbserver: Use std::list for all_processes Remove the usage of inferior_list for the all_processes list in gdbserver, replace it with an std::list. The entry field in process_info is removed, and replaced by a simple pid field. The pid_of macro, used for both processes and threads, is replaced with separate functions. For completeness, I changed ptid_of and lwpid_of to functions as well. gdb/gdbserver/ChangeLog: * gdbthread.h (ptid_of, pid_of, lwpid_of): New functions. * inferiors.h: Include <list>. (struct process_info) <entry>: Remove field. <pid>: New field. (pid_of): Change macro to function. (ptid_of, lwpid_of): Remove macro. (all_processes): Change type to std::list<process_info *>. (ALL_PROCESSES): Remove macro. (for_each_process, find_process): New function. * inferiors.c (all_processes): Change type to std::list<process_info *>. (find_thread_process): Adjust. (add_process): Likewise. (remove_process): Likewise. (find_process_pid): Likewise. (get_first_process): Likewise. (started_inferior_callback): Remove. (have_started_inferiors_p): Adjust. (attached_inferior_callback): Remove. (have_attached_inferiors_p): Adjust. * linux-low.c (check_zombie_leaders): Likewise. * linux-x86-low.c (x86_arch_setup_process_callback): Remove. (x86_linux_update_xmltarget): Adjust. * server.c (handle_query): Likewise. (gdb_reattached_process): Remove. (handle_status): Adjust. (kill_inferior_callback): Likewise. (detach_or_kill_inferior): Remove. (print_started_pid): Likewise. (print_attached_pid): Likewise. (detach_or_kill_for_exit): Update. (process_serial_event): Likewise. * linux-arm-low.c (arm_new_fork): Likewise.
2017-10-14 15:10:42 +02:00
pid_t leader_pid = pid_of (proc);
struct lwp_info *leader_lp;
leader_lp = find_lwp_pid (ptid_t (leader_pid));
gdbserver: Use std::list for all_processes Remove the usage of inferior_list for the all_processes list in gdbserver, replace it with an std::list. The entry field in process_info is removed, and replaced by a simple pid field. The pid_of macro, used for both processes and threads, is replaced with separate functions. For completeness, I changed ptid_of and lwpid_of to functions as well. gdb/gdbserver/ChangeLog: * gdbthread.h (ptid_of, pid_of, lwpid_of): New functions. * inferiors.h: Include <list>. (struct process_info) <entry>: Remove field. <pid>: New field. (pid_of): Change macro to function. (ptid_of, lwpid_of): Remove macro. (all_processes): Change type to std::list<process_info *>. (ALL_PROCESSES): Remove macro. (for_each_process, find_process): New function. * inferiors.c (all_processes): Change type to std::list<process_info *>. (find_thread_process): Adjust. (add_process): Likewise. (remove_process): Likewise. (find_process_pid): Likewise. (get_first_process): Likewise. (started_inferior_callback): Remove. (have_started_inferiors_p): Adjust. (attached_inferior_callback): Remove. (have_attached_inferiors_p): Adjust. * linux-low.c (check_zombie_leaders): Likewise. * linux-x86-low.c (x86_arch_setup_process_callback): Remove. (x86_linux_update_xmltarget): Adjust. * server.c (handle_query): Likewise. (gdb_reattached_process): Remove. (handle_status): Adjust. (kill_inferior_callback): Likewise. (detach_or_kill_inferior): Remove. (print_started_pid): Likewise. (print_attached_pid): Likewise. (detach_or_kill_for_exit): Update. (process_serial_event): Likewise. * linux-arm-low.c (arm_new_fork): Likewise.
2017-10-14 15:10:42 +02:00
if (debug_threads)
debug_printf ("leader_pid=%d, leader_lp!=NULL=%d, "
"num_lwps=%d, zombie=%d\n",
leader_pid, leader_lp!= NULL, num_lwps (leader_pid),
linux_proc_pid_is_zombie (leader_pid));
if (leader_lp != NULL && !leader_lp->stopped
/* Check if there are other threads in the group, as we may
have raced with the inferior simply exiting. */
&& !last_thread_of_process_p (leader_pid)
&& linux_proc_pid_is_zombie (leader_pid))
{
/* A leader zombie can mean one of two things:
- It exited, and there's an exit status pending
available, or only the leader exited (not the whole
program). In the latter case, we can't waitpid the
leader's exit status until all other threads are gone.
- There are 3 or more threads in the group, and a thread
other than the leader exec'd. On an exec, the Linux
kernel destroys all other threads (except the execing
one) in the thread group, and resets the execing thread's
tid to the tgid. No exit notification is sent for the
execing thread -- from the ptracer's perspective, it
appears as though the execing thread just vanishes.
Until we reap all other threads except the leader and the
execing thread, the leader will be zombie, and the
execing thread will be in `D (disc sleep)'. As soon as
all other threads are reaped, the execing thread changes
it's tid to the tgid, and the previous (zombie) leader
vanishes, giving place to the "new" leader. We could try
distinguishing the exit and exec cases, by waiting once
more, and seeing if something comes out, but it doesn't
sound useful. The previous leader _does_ go away, and
we'll re-add the new one once we see the exec event
(which is just the same as what would happen if the
previous leader did exit voluntarily before some other
thread execs). */
if (debug_threads)
debug_printf ("CZL: Thread group leader %d zombie "
"(it exited, or another thread execd).\n",
leader_pid);
delete_lwp (leader_lp);
}
});
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
}
/* Callback for `find_thread'. Returns the first LWP that is not
stopped. */
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
static bool
not_stopped_callback (thread_info *thread, ptid_t filter)
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
{
if (!thread->id.matches (filter))
return false;
lwp_info *lwp = get_thread_lwp (thread);
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
return !lwp->stopped;
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
}
gdbserver: Fix non-stop / fork / step-over issues Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html This adds a test that has a multithreaded program have several threads continuously fork, while another thread continuously steps over a breakpoint. This exposes several intertwined issues, which this patch addresses: - When we're stopping and suspending threads, some thread may fork, and we missed setting its suspend count to 1, like we do when a new clone/thread is detected. When we next unsuspend threads, the fork child's suspend count goes below 0, which is bogus and fails an assertion. - If a step-over is cancelled because a signal arrives, but then gdb is not interested in the signal, we pass the signal straight back to the inferior. However, we miss that we need to re-increment the suspend counts of all other threads that had been paused for the step-over. As a result, other threads indefinitely end up stuck stopped. - If a detach request comes in just while gdbserver is handling a step-over (in the test at hand, this is GDB detaching the fork child), gdbserver internal errors in stabilize_thread's helpers, which assert that all thread's suspend counts are 0 (otherwise we wouldn't be able to move threads out of the jump pads). The suspend counts aren't 0 while a step-over is in progress, because all threads but the one stepping past the breakpoint must remain paused until the step-over finishes and the breakpoint can be reinserted. - Occasionally, we see "BAD - reinserting but not stepping." being output (from within linux_resume_one_lwp_throw). That was because GDB pokes memory while gdbserver is busy with a step-over, and that suspends threads, and then re-resumes them with proceed_one_lwp, which missed another reason to tell linux_resume_one_lwp that the thread should be set back to stepping. - In a couple places, we were resuming threads that are meant to be suspended. E.g., when a vCont;c/s request for thread B comes in just while gdbserver is stepping thread A past a breakpoint. The resume for thread B must be deferred until the step-over finishes. - The test runs with both "set detach-on-fork" on and off. When off, it exercises the case of GDB detaching the fork child explicitly. When on, it exercises the case of gdb resuming the child explicitly. In the "off" case, gdb seems to exponentially become slower as new inferiors are created. This is _very_ noticeable as with only 100 inferiors gdb is crawling already, which makes the test take quite a bit to run. For that reason, I've disabled the "off" variant for now. gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * target/waitstatus.h (enum target_stop_reason) <TARGET_STOPPED_BY_SINGLE_STEP>: New value. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the fork child's suspend count if stopping and suspending threads. (check_stopped_by_breakpoint): If stopped by trace, set the LWP's stop reason to TARGET_STOPPED_BY_SINGLE_STEP. (linux_detach): Complete an ongoing step-over. (lwp_suspended_inc, lwp_suspended_decr): New functions. Use throughout. (resume_stopped_resumed_lwps): Don't resume a suspended thread. (linux_wait_1): If passing a signal to the inferior after finishing a step-over, unsuspend and re-resume all lwps. If we see a single-step event but the thread should be continuing, don't pass the trap to gdb. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use internal_error instead of gdb_assert. (enqueue_pending_signal): New function. (check_ptrace_stopped_lwp_gone): Add debug output. (start_step_over): Use internal_error instead of gdb_assert. (complete_ongoing_step_over): New function. (linux_resume_one_thread): Don't resume a suspended thread. (proceed_one_lwp): If the LWP is stepping over a breakpoint, reset it stepping. gdb/testsuite/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * gdb.threads/forking-threads-plus-breakpoint.exp: New file. * gdb.threads/forking-threads-plus-breakpoint.c: New file.
2015-08-06 11:30:18 +02:00
/* Increment LWP's suspend count. */
static void
lwp_suspended_inc (struct lwp_info *lwp)
{
lwp->suspended++;
if (debug_threads && lwp->suspended > 4)
{
struct thread_info *thread = get_lwp_thread (lwp);
debug_printf ("LWP %ld has a suspiciously high suspend count,"
" suspended=%d\n", lwpid_of (thread), lwp->suspended);
}
}
/* Decrement LWP's suspend count. */
static void
lwp_suspended_decr (struct lwp_info *lwp)
{
lwp->suspended--;
if (lwp->suspended < 0)
{
struct thread_info *thread = get_lwp_thread (lwp);
internal_error (__FILE__, __LINE__,
"unsuspend LWP %ld, suspended=%d\n", lwpid_of (thread),
lwp->suspended);
}
}
gdb/gdbserver/ * server.h (LONGEST): New. (struct thread_info) <while_stepping>: New field. (unpack_varlen_hex, xrealloc, pulongest, plongest, phex_nz): Declare. (initialize_tracepoint, handle_tracepoint_general_set) (handle_tracepoint_query, tracepoint_finished_step) (tracepoint_was_hit, release_while_stepping_state_list): (current_traceframe): Declare. * server.c (handle_general_set): Handle tracepoint packets. (read_memory): New. (write_memory): New. (handle_search_memory_1): Use read_memory. (handle_query): Report support for conditional tracepoints, trace state variables, and tracepoint sources. Handle tracepoint queries. (main): Initialize the tracepoints module. (process_serial_event): Handle traceframe reads/writes. * linux-low.c (handle_tracepoints): New. (linux_wait_1): Call it. (linux_resume_one_lwp): Handle while-stepping. (linux_supports_tracepoints, linux_read_pc, linux_write_pc): New. (linux_target_ops): Install them. * linux-low.h (struct linux_target_ops) <supports_tracepoints>: New field. * linux-x86-low.c (x86_supports_tracepoints): New. (the_low_target). Install it. * mem-break.h (delete_breakpoint): Declare. * mem-break.c (delete_breakpoint): Make external. * target.h (struct target_ops): Add `supports_tracepoints', `read_pc', and `write_pc' fields. (target_supports_tracepoints): Define. * utils.c (xrealloc, decimal2str, pulongest, plongest, thirty_two) (phex_nz): New. * regcache.h (struct regcache) <registers_owned>: New field. (init_register_cache, regcache_cpy): Declare. (regcache_read_pc, regcache_write_pc): Declare. (register_cache_size): Declare. (supply_regblock): Declare. * regcache.c (init_register_cache): New. (new_register_cache): Use it. (regcache_cpy): New. (register_cache_size): New. (supply_regblock): New. (regcache_read_pc, regcache_write_pc): New. * tracepoint.c: New. * Makefile.in (OBS): Add tracepoint.o. (tracepoint.o): New rule. gdb/ * regformats/regdat.sh: Include server.h. Don't include regcache.h.
2010-04-09 05:40:00 +02:00
/* This function should only be called if the LWP got a SIGTRAP.
Handle any tracepoint steps or hits. Return true if a tracepoint
event was handled, 0 otherwise. */
static int
handle_tracepoints (struct lwp_info *lwp)
{
struct thread_info *tinfo = get_lwp_thread (lwp);
int tpoint_related_event = 0;
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
gdb_assert (lwp->suspended == 0);
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
/* If this tracepoint hit causes a tracing stop, we'll immediately
uninsert tracepoints. To do this, we temporarily pause all
threads, unpatch away, and then unpause threads. We need to make
sure the unpausing doesn't resume LWP too. */
gdbserver: Fix non-stop / fork / step-over issues Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html This adds a test that has a multithreaded program have several threads continuously fork, while another thread continuously steps over a breakpoint. This exposes several intertwined issues, which this patch addresses: - When we're stopping and suspending threads, some thread may fork, and we missed setting its suspend count to 1, like we do when a new clone/thread is detected. When we next unsuspend threads, the fork child's suspend count goes below 0, which is bogus and fails an assertion. - If a step-over is cancelled because a signal arrives, but then gdb is not interested in the signal, we pass the signal straight back to the inferior. However, we miss that we need to re-increment the suspend counts of all other threads that had been paused for the step-over. As a result, other threads indefinitely end up stuck stopped. - If a detach request comes in just while gdbserver is handling a step-over (in the test at hand, this is GDB detaching the fork child), gdbserver internal errors in stabilize_thread's helpers, which assert that all thread's suspend counts are 0 (otherwise we wouldn't be able to move threads out of the jump pads). The suspend counts aren't 0 while a step-over is in progress, because all threads but the one stepping past the breakpoint must remain paused until the step-over finishes and the breakpoint can be reinserted. - Occasionally, we see "BAD - reinserting but not stepping." being output (from within linux_resume_one_lwp_throw). That was because GDB pokes memory while gdbserver is busy with a step-over, and that suspends threads, and then re-resumes them with proceed_one_lwp, which missed another reason to tell linux_resume_one_lwp that the thread should be set back to stepping. - In a couple places, we were resuming threads that are meant to be suspended. E.g., when a vCont;c/s request for thread B comes in just while gdbserver is stepping thread A past a breakpoint. The resume for thread B must be deferred until the step-over finishes. - The test runs with both "set detach-on-fork" on and off. When off, it exercises the case of GDB detaching the fork child explicitly. When on, it exercises the case of gdb resuming the child explicitly. In the "off" case, gdb seems to exponentially become slower as new inferiors are created. This is _very_ noticeable as with only 100 inferiors gdb is crawling already, which makes the test take quite a bit to run. For that reason, I've disabled the "off" variant for now. gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * target/waitstatus.h (enum target_stop_reason) <TARGET_STOPPED_BY_SINGLE_STEP>: New value. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the fork child's suspend count if stopping and suspending threads. (check_stopped_by_breakpoint): If stopped by trace, set the LWP's stop reason to TARGET_STOPPED_BY_SINGLE_STEP. (linux_detach): Complete an ongoing step-over. (lwp_suspended_inc, lwp_suspended_decr): New functions. Use throughout. (resume_stopped_resumed_lwps): Don't resume a suspended thread. (linux_wait_1): If passing a signal to the inferior after finishing a step-over, unsuspend and re-resume all lwps. If we see a single-step event but the thread should be continuing, don't pass the trap to gdb. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use internal_error instead of gdb_assert. (enqueue_pending_signal): New function. (check_ptrace_stopped_lwp_gone): Add debug output. (start_step_over): Use internal_error instead of gdb_assert. (complete_ongoing_step_over): New function. (linux_resume_one_thread): Don't resume a suspended thread. (proceed_one_lwp): If the LWP is stepping over a breakpoint, reset it stepping. gdb/testsuite/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * gdb.threads/forking-threads-plus-breakpoint.exp: New file. * gdb.threads/forking-threads-plus-breakpoint.c: New file.
2015-08-06 11:30:18 +02:00
lwp_suspended_inc (lwp);
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
gdb/gdbserver/ * server.h (LONGEST): New. (struct thread_info) <while_stepping>: New field. (unpack_varlen_hex, xrealloc, pulongest, plongest, phex_nz): Declare. (initialize_tracepoint, handle_tracepoint_general_set) (handle_tracepoint_query, tracepoint_finished_step) (tracepoint_was_hit, release_while_stepping_state_list): (current_traceframe): Declare. * server.c (handle_general_set): Handle tracepoint packets. (read_memory): New. (write_memory): New. (handle_search_memory_1): Use read_memory. (handle_query): Report support for conditional tracepoints, trace state variables, and tracepoint sources. Handle tracepoint queries. (main): Initialize the tracepoints module. (process_serial_event): Handle traceframe reads/writes. * linux-low.c (handle_tracepoints): New. (linux_wait_1): Call it. (linux_resume_one_lwp): Handle while-stepping. (linux_supports_tracepoints, linux_read_pc, linux_write_pc): New. (linux_target_ops): Install them. * linux-low.h (struct linux_target_ops) <supports_tracepoints>: New field. * linux-x86-low.c (x86_supports_tracepoints): New. (the_low_target). Install it. * mem-break.h (delete_breakpoint): Declare. * mem-break.c (delete_breakpoint): Make external. * target.h (struct target_ops): Add `supports_tracepoints', `read_pc', and `write_pc' fields. (target_supports_tracepoints): Define. * utils.c (xrealloc, decimal2str, pulongest, plongest, thirty_two) (phex_nz): New. * regcache.h (struct regcache) <registers_owned>: New field. (init_register_cache, regcache_cpy): Declare. (regcache_read_pc, regcache_write_pc): Declare. (register_cache_size): Declare. (supply_regblock): Declare. * regcache.c (init_register_cache): New. (new_register_cache): Use it. (regcache_cpy): New. (register_cache_size): New. (supply_regblock): New. (regcache_read_pc, regcache_write_pc): New. * tracepoint.c: New. * Makefile.in (OBS): Add tracepoint.o. (tracepoint.o): New rule. gdb/ * regformats/regdat.sh: Include server.h. Don't include regcache.h.
2010-04-09 05:40:00 +02:00
/* And we need to be sure that any all-threads-stopping doesn't try
to move threads out of the jump pads, as it could deadlock the
inferior (LWP could be in the jump pad, maybe even holding the
lock.) */
/* Do any necessary step collect actions. */
tpoint_related_event |= tracepoint_finished_step (tinfo, lwp->stop_pc);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
tpoint_related_event |= handle_tracepoint_bkpts (tinfo, lwp->stop_pc);
gdb/gdbserver/ * server.h (LONGEST): New. (struct thread_info) <while_stepping>: New field. (unpack_varlen_hex, xrealloc, pulongest, plongest, phex_nz): Declare. (initialize_tracepoint, handle_tracepoint_general_set) (handle_tracepoint_query, tracepoint_finished_step) (tracepoint_was_hit, release_while_stepping_state_list): (current_traceframe): Declare. * server.c (handle_general_set): Handle tracepoint packets. (read_memory): New. (write_memory): New. (handle_search_memory_1): Use read_memory. (handle_query): Report support for conditional tracepoints, trace state variables, and tracepoint sources. Handle tracepoint queries. (main): Initialize the tracepoints module. (process_serial_event): Handle traceframe reads/writes. * linux-low.c (handle_tracepoints): New. (linux_wait_1): Call it. (linux_resume_one_lwp): Handle while-stepping. (linux_supports_tracepoints, linux_read_pc, linux_write_pc): New. (linux_target_ops): Install them. * linux-low.h (struct linux_target_ops) <supports_tracepoints>: New field. * linux-x86-low.c (x86_supports_tracepoints): New. (the_low_target). Install it. * mem-break.h (delete_breakpoint): Declare. * mem-break.c (delete_breakpoint): Make external. * target.h (struct target_ops): Add `supports_tracepoints', `read_pc', and `write_pc' fields. (target_supports_tracepoints): Define. * utils.c (xrealloc, decimal2str, pulongest, plongest, thirty_two) (phex_nz): New. * regcache.h (struct regcache) <registers_owned>: New field. (init_register_cache, regcache_cpy): Declare. (regcache_read_pc, regcache_write_pc): Declare. (register_cache_size): Declare. (supply_regblock): Declare. * regcache.c (init_register_cache): New. (new_register_cache): Use it. (regcache_cpy): New. (register_cache_size): New. (supply_regblock): New. (regcache_read_pc, regcache_write_pc): New. * tracepoint.c: New. * Makefile.in (OBS): Add tracepoint.o. (tracepoint.o): New rule. gdb/ * regformats/regdat.sh: Include server.h. Don't include regcache.h.
2010-04-09 05:40:00 +02:00
/* See if we just hit a tracepoint and do its main collect
actions. */
tpoint_related_event |= tracepoint_was_hit (tinfo, lwp->stop_pc);
gdbserver: Fix non-stop / fork / step-over issues Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html This adds a test that has a multithreaded program have several threads continuously fork, while another thread continuously steps over a breakpoint. This exposes several intertwined issues, which this patch addresses: - When we're stopping and suspending threads, some thread may fork, and we missed setting its suspend count to 1, like we do when a new clone/thread is detected. When we next unsuspend threads, the fork child's suspend count goes below 0, which is bogus and fails an assertion. - If a step-over is cancelled because a signal arrives, but then gdb is not interested in the signal, we pass the signal straight back to the inferior. However, we miss that we need to re-increment the suspend counts of all other threads that had been paused for the step-over. As a result, other threads indefinitely end up stuck stopped. - If a detach request comes in just while gdbserver is handling a step-over (in the test at hand, this is GDB detaching the fork child), gdbserver internal errors in stabilize_thread's helpers, which assert that all thread's suspend counts are 0 (otherwise we wouldn't be able to move threads out of the jump pads). The suspend counts aren't 0 while a step-over is in progress, because all threads but the one stepping past the breakpoint must remain paused until the step-over finishes and the breakpoint can be reinserted. - Occasionally, we see "BAD - reinserting but not stepping." being output (from within linux_resume_one_lwp_throw). That was because GDB pokes memory while gdbserver is busy with a step-over, and that suspends threads, and then re-resumes them with proceed_one_lwp, which missed another reason to tell linux_resume_one_lwp that the thread should be set back to stepping. - In a couple places, we were resuming threads that are meant to be suspended. E.g., when a vCont;c/s request for thread B comes in just while gdbserver is stepping thread A past a breakpoint. The resume for thread B must be deferred until the step-over finishes. - The test runs with both "set detach-on-fork" on and off. When off, it exercises the case of GDB detaching the fork child explicitly. When on, it exercises the case of gdb resuming the child explicitly. In the "off" case, gdb seems to exponentially become slower as new inferiors are created. This is _very_ noticeable as with only 100 inferiors gdb is crawling already, which makes the test take quite a bit to run. For that reason, I've disabled the "off" variant for now. gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * target/waitstatus.h (enum target_stop_reason) <TARGET_STOPPED_BY_SINGLE_STEP>: New value. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the fork child's suspend count if stopping and suspending threads. (check_stopped_by_breakpoint): If stopped by trace, set the LWP's stop reason to TARGET_STOPPED_BY_SINGLE_STEP. (linux_detach): Complete an ongoing step-over. (lwp_suspended_inc, lwp_suspended_decr): New functions. Use throughout. (resume_stopped_resumed_lwps): Don't resume a suspended thread. (linux_wait_1): If passing a signal to the inferior after finishing a step-over, unsuspend and re-resume all lwps. If we see a single-step event but the thread should be continuing, don't pass the trap to gdb. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use internal_error instead of gdb_assert. (enqueue_pending_signal): New function. (check_ptrace_stopped_lwp_gone): Add debug output. (start_step_over): Use internal_error instead of gdb_assert. (complete_ongoing_step_over): New function. (linux_resume_one_thread): Don't resume a suspended thread. (proceed_one_lwp): If the LWP is stepping over a breakpoint, reset it stepping. gdb/testsuite/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * gdb.threads/forking-threads-plus-breakpoint.exp: New file. * gdb.threads/forking-threads-plus-breakpoint.c: New file.
2015-08-06 11:30:18 +02:00
lwp_suspended_decr (lwp);
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
gdb_assert (lwp->suspended == 0);
gdb_assert (!stabilizing_threads
|| (lwp->collecting_fast_tracepoint
!= fast_tpoint_collect_result::not_collecting));
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
gdb/gdbserver/ * server.h (LONGEST): New. (struct thread_info) <while_stepping>: New field. (unpack_varlen_hex, xrealloc, pulongest, plongest, phex_nz): Declare. (initialize_tracepoint, handle_tracepoint_general_set) (handle_tracepoint_query, tracepoint_finished_step) (tracepoint_was_hit, release_while_stepping_state_list): (current_traceframe): Declare. * server.c (handle_general_set): Handle tracepoint packets. (read_memory): New. (write_memory): New. (handle_search_memory_1): Use read_memory. (handle_query): Report support for conditional tracepoints, trace state variables, and tracepoint sources. Handle tracepoint queries. (main): Initialize the tracepoints module. (process_serial_event): Handle traceframe reads/writes. * linux-low.c (handle_tracepoints): New. (linux_wait_1): Call it. (linux_resume_one_lwp): Handle while-stepping. (linux_supports_tracepoints, linux_read_pc, linux_write_pc): New. (linux_target_ops): Install them. * linux-low.h (struct linux_target_ops) <supports_tracepoints>: New field. * linux-x86-low.c (x86_supports_tracepoints): New. (the_low_target). Install it. * mem-break.h (delete_breakpoint): Declare. * mem-break.c (delete_breakpoint): Make external. * target.h (struct target_ops): Add `supports_tracepoints', `read_pc', and `write_pc' fields. (target_supports_tracepoints): Define. * utils.c (xrealloc, decimal2str, pulongest, plongest, thirty_two) (phex_nz): New. * regcache.h (struct regcache) <registers_owned>: New field. (init_register_cache, regcache_cpy): Declare. (regcache_read_pc, regcache_write_pc): Declare. (register_cache_size): Declare. (supply_regblock): Declare. * regcache.c (init_register_cache): New. (new_register_cache): Use it. (regcache_cpy): New. (register_cache_size): New. (supply_regblock): New. (regcache_read_pc, regcache_write_pc): New. * tracepoint.c: New. * Makefile.in (OBS): Add tracepoint.o. (tracepoint.o): New rule. gdb/ * regformats/regdat.sh: Include server.h. Don't include regcache.h.
2010-04-09 05:40:00 +02:00
if (tpoint_related_event)
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("got a tracepoint event\n");
gdb/gdbserver/ * server.h (LONGEST): New. (struct thread_info) <while_stepping>: New field. (unpack_varlen_hex, xrealloc, pulongest, plongest, phex_nz): Declare. (initialize_tracepoint, handle_tracepoint_general_set) (handle_tracepoint_query, tracepoint_finished_step) (tracepoint_was_hit, release_while_stepping_state_list): (current_traceframe): Declare. * server.c (handle_general_set): Handle tracepoint packets. (read_memory): New. (write_memory): New. (handle_search_memory_1): Use read_memory. (handle_query): Report support for conditional tracepoints, trace state variables, and tracepoint sources. Handle tracepoint queries. (main): Initialize the tracepoints module. (process_serial_event): Handle traceframe reads/writes. * linux-low.c (handle_tracepoints): New. (linux_wait_1): Call it. (linux_resume_one_lwp): Handle while-stepping. (linux_supports_tracepoints, linux_read_pc, linux_write_pc): New. (linux_target_ops): Install them. * linux-low.h (struct linux_target_ops) <supports_tracepoints>: New field. * linux-x86-low.c (x86_supports_tracepoints): New. (the_low_target). Install it. * mem-break.h (delete_breakpoint): Declare. * mem-break.c (delete_breakpoint): Make external. * target.h (struct target_ops): Add `supports_tracepoints', `read_pc', and `write_pc' fields. (target_supports_tracepoints): Define. * utils.c (xrealloc, decimal2str, pulongest, plongest, thirty_two) (phex_nz): New. * regcache.h (struct regcache) <registers_owned>: New field. (init_register_cache, regcache_cpy): Declare. (regcache_read_pc, regcache_write_pc): Declare. (register_cache_size): Declare. (supply_regblock): Declare. * regcache.c (init_register_cache): New. (new_register_cache): Use it. (regcache_cpy): New. (register_cache_size): New. (supply_regblock): New. (regcache_read_pc, regcache_write_pc): New. * tracepoint.c: New. * Makefile.in (OBS): Add tracepoint.o. (tracepoint.o): New rule. gdb/ * regformats/regdat.sh: Include server.h. Don't include regcache.h.
2010-04-09 05:40:00 +02:00
return 1;
}
return 0;
}
gdbserver/linux-low: turn 'get_thread_area' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_thread_area' linux target op into a method of process_stratum_target. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <stuck_in_jump_pad> <linux_fast_tracepoint_collecting> <low_get_thread_area>: Declare. * linux-low.cc (supports_fast_tracepoints): Remove. (linux_fast_tracepoint_collecting): Turn into... (linux_process_target::linux_fast_tracepoint_collecting): ...this. (linux_process_target::low_get_thread_area): Define. (stuck_in_jump_pad_callback): Turn into... (linux_process_target::stuck_in_jump_pad): ...this. Update the caller below. (linux_process_target::stabilize_threads) * linux-x86-low.cc (class x86_target) <low_get_thread_area>: Declare. (x86_get_thread_area): Turn into... (x86_target::low_get_thread_area): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <low_get_thread_area>: Declare. (aarch64_get_thread_area): Turn into... (aarch64_target::low_get_thread_area): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (class ppc_target) <low_get_thread_area>: Declare. (ppc_get_thread_area): Turn into... (ppc_target::low_get_thread_area): ...this. (the_low_target): Remove the op field. * linux-s390-low.cc (class s390_target) <low_get_thread_area>: Declare. (s390_get_thread_area): Turn into... (s390_target::low_get_thread_area): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (the_low_target): Remove the op field. * linux-bfin-low.cc (the_low_target): Ditto. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:30 +02:00
fast_tpoint_collect_result
linux_process_target::linux_fast_tracepoint_collecting
(lwp_info *lwp, fast_tpoint_collect_status *status)
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
{
CORE_ADDR thread_area;
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
struct thread_info *thread = get_lwp_thread (lwp);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
/* Get the thread area address. This is used to recognize which
thread is which when tracing with the in-process agent library.
We don't read anything from the address, and treat it as opaque;
it's the address itself that we assume is unique per-thread. */
gdbserver/linux-low: turn 'get_thread_area' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_thread_area' linux target op into a method of process_stratum_target. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <stuck_in_jump_pad> <linux_fast_tracepoint_collecting> <low_get_thread_area>: Declare. * linux-low.cc (supports_fast_tracepoints): Remove. (linux_fast_tracepoint_collecting): Turn into... (linux_process_target::linux_fast_tracepoint_collecting): ...this. (linux_process_target::low_get_thread_area): Define. (stuck_in_jump_pad_callback): Turn into... (linux_process_target::stuck_in_jump_pad): ...this. Update the caller below. (linux_process_target::stabilize_threads) * linux-x86-low.cc (class x86_target) <low_get_thread_area>: Declare. (x86_get_thread_area): Turn into... (x86_target::low_get_thread_area): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <low_get_thread_area>: Declare. (aarch64_get_thread_area): Turn into... (aarch64_target::low_get_thread_area): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (class ppc_target) <low_get_thread_area>: Declare. (ppc_get_thread_area): Turn into... (ppc_target::low_get_thread_area): ...this. (the_low_target): Remove the op field. * linux-s390-low.cc (class s390_target) <low_get_thread_area>: Declare. (s390_get_thread_area): Turn into... (s390_target::low_get_thread_area): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (the_low_target): Remove the op field. * linux-bfin-low.cc (the_low_target): Ditto. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:30 +02:00
if (low_get_thread_area (lwpid_of (thread), &thread_area) == -1)
return fast_tpoint_collect_result::not_collecting;
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
return fast_tracepoint_collecting (thread_area, lwp->stop_pc, status);
}
gdbserver/linux-low: turn 'get_thread_area' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_thread_area' linux target op into a method of process_stratum_target. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <stuck_in_jump_pad> <linux_fast_tracepoint_collecting> <low_get_thread_area>: Declare. * linux-low.cc (supports_fast_tracepoints): Remove. (linux_fast_tracepoint_collecting): Turn into... (linux_process_target::linux_fast_tracepoint_collecting): ...this. (linux_process_target::low_get_thread_area): Define. (stuck_in_jump_pad_callback): Turn into... (linux_process_target::stuck_in_jump_pad): ...this. Update the caller below. (linux_process_target::stabilize_threads) * linux-x86-low.cc (class x86_target) <low_get_thread_area>: Declare. (x86_get_thread_area): Turn into... (x86_target::low_get_thread_area): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <low_get_thread_area>: Declare. (aarch64_get_thread_area): Turn into... (aarch64_target::low_get_thread_area): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (class ppc_target) <low_get_thread_area>: Declare. (ppc_get_thread_area): Turn into... (ppc_target::low_get_thread_area): ...this. (the_low_target): Remove the op field. * linux-s390-low.cc (class s390_target) <low_get_thread_area>: Declare. (s390_get_thread_area): Turn into... (s390_target::low_get_thread_area): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (the_low_target): Remove the op field. * linux-bfin-low.cc (the_low_target): Ditto. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:30 +02:00
int
linux_process_target::low_get_thread_area (int lwpid, CORE_ADDR *addrp)
{
return -1;
}
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
bool
linux_process_target::maybe_move_out_of_jump_pad (lwp_info *lwp, int *wstat)
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
{
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
struct thread_info *saved_thread;
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
saved_thread = current_thread;
current_thread = get_lwp_thread (lwp);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
if ((wstat == NULL
|| (WIFSTOPPED (*wstat) && WSTOPSIG (*wstat) != SIGTRAP))
&& supports_fast_tracepoints ()
&& agent_loaded_p ())
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
{
struct fast_tpoint_collect_status status;
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Checking whether LWP %ld needs to move out of the "
"jump pad.\n",
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
lwpid_of (current_thread));
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
fast_tpoint_collect_result r
= linux_fast_tracepoint_collecting (lwp, &status);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
if (wstat == NULL
|| (WSTOPSIG (*wstat) != SIGILL
&& WSTOPSIG (*wstat) != SIGFPE
&& WSTOPSIG (*wstat) != SIGSEGV
&& WSTOPSIG (*wstat) != SIGBUS))
{
lwp->collecting_fast_tracepoint = r;
if (r != fast_tpoint_collect_result::not_collecting)
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
{
if (r == fast_tpoint_collect_result::before_insn
&& lwp->exit_jump_pad_bkpt == NULL)
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
{
/* Haven't executed the original instruction yet.
Set breakpoint there, and wait till it's hit,
then single-step until exiting the jump pad. */
lwp->exit_jump_pad_bkpt
= set_breakpoint_at (status.adjusted_insn_addr, NULL);
}
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Checking whether LWP %ld needs to move out of "
"the jump pad...it does\n",
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
lwpid_of (current_thread));
current_thread = saved_thread;
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
return true;
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
}
}
else
{
/* If we get a synchronous signal while collecting, *and*
while executing the (relocated) original instruction,
reset the PC to point at the tpoint address, before
reporting to GDB. Otherwise, it's an IPA lib bug: just
report the signal to GDB, and pray for the best. */
lwp->collecting_fast_tracepoint
= fast_tpoint_collect_result::not_collecting;
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
if (r != fast_tpoint_collect_result::not_collecting
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
&& (status.adjusted_insn_addr <= lwp->stop_pc
&& lwp->stop_pc < status.adjusted_insn_addr_end))
{
siginfo_t info;
struct regcache *regcache;
/* The si_addr on a few signals references the address
of the faulting instruction. Adjust that as
well. */
if ((WSTOPSIG (*wstat) == SIGILL
|| WSTOPSIG (*wstat) == SIGFPE
|| WSTOPSIG (*wstat) == SIGBUS
|| WSTOPSIG (*wstat) == SIGSEGV)
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
&& ptrace (PTRACE_GETSIGINFO, lwpid_of (current_thread),
(PTRACE_TYPE_ARG3) 0, &info) == 0
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
/* Final check just to make sure we don't clobber
the siginfo of non-kernel-sent signals. */
&& (uintptr_t) info.si_addr == lwp->stop_pc)
{
info.si_addr = (void *) (uintptr_t) status.tpoint_addr;
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
ptrace (PTRACE_SETSIGINFO, lwpid_of (current_thread),
(PTRACE_TYPE_ARG3) 0, &info);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
}
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
regcache = get_thread_regcache (current_thread, 1);
gdbserver/linux-low: turn 'get_pc' and 'set_pc' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_pc' and 'set_pc' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. * linux-low.cc (supports_breakpoints): Turn into... (linux_process_target::low_supports_breakpoints): ...this. (linux_process_target::low_get_pc): Define. (linux_process_target::low_set_pc): Define. Update the callers below. (linux_process_target::get_pc) (linux_process_target::save_stop_reason) (linux_process_target::maybe_move_out_of_jump_pad) (linux_process_target::wait_1) (linux_process_target::resume_one_lwp_throw) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (linux_process_target::read_pc) (linux_process_target::write_pc) * linux-x86-low.cc (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (x86_target::low_supports_breakpoints): Define. (x86_get_pc): Turn into... (x86_target::low_get_pc): ...this. (x86_set_pc): Turn into... (x86_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (arm_target::low_supports_breakpoints) (arm_target::low_get_pc) (arm_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (bfin_target::low_supports_breakpoints) (bfin_target::low_get_pc) (bfin_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (cris_target::low_supports_breakpoints) (cris_target::low_get_pc) (cris_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (crisv32_target::low_supports_breakpoints) (crisv32_target::low_get_pc) (crisv32_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m32r_target::low_supports_breakpoints) (m32r_target::low_get_pc) (m32r_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m68k_target::low_supports_breakpoints) (m68k_target::low_get_pc) (m68k_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (nios2_target::low_supports_breakpoints) (nios2_target::low_get_pc) (nios2_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (sh_target::low_supports_breakpoints) (sh_target::low_get_pc) (sh_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (xtensa_target::low_supports_breakpoints) (xtensa_target::low_get_pc) (xtensa_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_supports_breakpoints> <low_get_pc>: Declare. (sparc_target::low_supports_breakpoints) (sparc_target::low_get_pc): Define. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tile_target::low_supports_breakpoints) (tile_target::low_get_pc) (tile_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (aarch64_target::low_supports_breakpoints): Define. (aarch64_get_pc): Turn into... (aarch64_target::low_get_pc): ...this. (aarch64_set_pc): Turn into... (aarch64_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (mips_target::low_supports_breakpoints): Define. (mips_get_pc): Turn into... (mips_target::low_get_pc): ...this. (mips_set_pc): Turn into... (mips_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (ppc_target::low_supports_breakpoints): Define. (ppc_get_pc): Turn into... (ppc_target::low_get_pc): ...this. (ppc_set_pc): Turn into... (ppc_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (riscv_target::low_supports_breakpoints): Define. (riscv_get_pc): Turn into... (riscv_target::low_get_pc): ...this. (riscv_set_pc): Turn into... (riscv_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (s390_target::low_supports_breakpoints): Define. (s390_get_pc): Turn into... (s390_target::low_get_pc): ...this. (s390_set_pc): Turn into... (s390_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tic6x_target::low_supports_breakpoints): Define. (tic6x_get_pc): Turn into... (tic6x_target::low_get_pc): ...this. (tic6x_set_pc): Turn into... (tic6x_target::low_set_pc): ...this. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
low_set_pc (regcache, status.tpoint_addr);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
lwp->stop_pc = status.tpoint_addr;
/* Cancel any fast tracepoint lock this thread was
holding. */
force_unlock_trace_buffer ();
}
if (lwp->exit_jump_pad_bkpt != NULL)
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Cancelling fast exit-jump-pad: removing bkpt. "
"stopping all threads momentarily.\n");
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
stop_all_lwps (1, lwp);
delete_breakpoint (lwp->exit_jump_pad_bkpt);
lwp->exit_jump_pad_bkpt = NULL;
unstop_all_lwps (1, lwp);
gdb_assert (lwp->suspended >= 0);
}
}
}
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Checking whether LWP %ld needs to move out of the "
"jump pad...no\n",
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
lwpid_of (current_thread));
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
current_thread = saved_thread;
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
return false;
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
}
/* Enqueue one signal in the "signals to report later when out of the
jump pad" list. */
static void
enqueue_one_deferred_signal (struct lwp_info *lwp, int *wstat)
{
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
struct thread_info *thread = get_lwp_thread (lwp);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Deferring signal %d for LWP %ld.\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
WSTOPSIG (*wstat), lwpid_of (thread));
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
if (debug_threads)
{
gdbserver/linux-low: use std::list to store pending signals Use std::list to store pending signals instead of a manually-managed linked list. This is a refactoring. In the existing code, pending signals are kept in a manually-created linked list with "prev" pointers. A new pending signal is thus inserted to the beginning of the list. When consuming, GDB goes until the end of the list, following the "prev" pointers, and processes the final item. With this patch, a new item is added to the end of the list and the item at the front of the list is consumed. In other words, the list elements used to be stored in reverse order; with this patch, they are stored in their order of arrival. This causes a change in the debug messages that print the pending signals. Otherwise, no behavioral change is expected. gdbserver/ChangeLog: 2020-06-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Use std::list to stop pending signal instead of manually-created linked list. * linux-low.h: Include <list>. (struct pending_signal): Move here from linux-low.cc. (struct lwp_info) <pending_signals> <pending_signals_to_report>: Update the type. * linux-low.cc (struct pending_signals): Remove. (linux_process_target::delete_lwp) (linux_process_target::add_lwp) (enqueue_one_deferred_signal) (dequeue_one_deferred_signal) (enqueue_pending_signal) (linux_process_target::resume_one_lwp_throw) (linux_process_target::thread_needs_step_over) (linux_process_target::resume_one_thread) (linux_process_target::proceed_one_lwp): Update the use of pending signal list.
2020-06-22 14:13:48 +02:00
for (const auto &sig : lwp->pending_signals_to_report)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf (" Already queued %d\n",
gdbserver/linux-low: use std::list to store pending signals Use std::list to store pending signals instead of a manually-managed linked list. This is a refactoring. In the existing code, pending signals are kept in a manually-created linked list with "prev" pointers. A new pending signal is thus inserted to the beginning of the list. When consuming, GDB goes until the end of the list, following the "prev" pointers, and processes the final item. With this patch, a new item is added to the end of the list and the item at the front of the list is consumed. In other words, the list elements used to be stored in reverse order; with this patch, they are stored in their order of arrival. This causes a change in the debug messages that print the pending signals. Otherwise, no behavioral change is expected. gdbserver/ChangeLog: 2020-06-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Use std::list to stop pending signal instead of manually-created linked list. * linux-low.h: Include <list>. (struct pending_signal): Move here from linux-low.cc. (struct lwp_info) <pending_signals> <pending_signals_to_report>: Update the type. * linux-low.cc (struct pending_signals): Remove. (linux_process_target::delete_lwp) (linux_process_target::add_lwp) (enqueue_one_deferred_signal) (dequeue_one_deferred_signal) (enqueue_pending_signal) (linux_process_target::resume_one_lwp_throw) (linux_process_target::thread_needs_step_over) (linux_process_target::resume_one_thread) (linux_process_target::proceed_one_lwp): Update the use of pending signal list.
2020-06-22 14:13:48 +02:00
sig.signal);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf (" (no more currently queued signals)\n");
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
}
/* Don't enqueue non-RT signals if they are already in the deferred
queue. (SIGSTOP being the easiest signal to see ending up here
twice) */
if (WSTOPSIG (*wstat) < __SIGRTMIN)
{
gdbserver/linux-low: use std::list to store pending signals Use std::list to store pending signals instead of a manually-managed linked list. This is a refactoring. In the existing code, pending signals are kept in a manually-created linked list with "prev" pointers. A new pending signal is thus inserted to the beginning of the list. When consuming, GDB goes until the end of the list, following the "prev" pointers, and processes the final item. With this patch, a new item is added to the end of the list and the item at the front of the list is consumed. In other words, the list elements used to be stored in reverse order; with this patch, they are stored in their order of arrival. This causes a change in the debug messages that print the pending signals. Otherwise, no behavioral change is expected. gdbserver/ChangeLog: 2020-06-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Use std::list to stop pending signal instead of manually-created linked list. * linux-low.h: Include <list>. (struct pending_signal): Move here from linux-low.cc. (struct lwp_info) <pending_signals> <pending_signals_to_report>: Update the type. * linux-low.cc (struct pending_signals): Remove. (linux_process_target::delete_lwp) (linux_process_target::add_lwp) (enqueue_one_deferred_signal) (dequeue_one_deferred_signal) (enqueue_pending_signal) (linux_process_target::resume_one_lwp_throw) (linux_process_target::thread_needs_step_over) (linux_process_target::resume_one_thread) (linux_process_target::proceed_one_lwp): Update the use of pending signal list.
2020-06-22 14:13:48 +02:00
for (const auto &sig : lwp->pending_signals_to_report)
{
gdbserver/linux-low: use std::list to store pending signals Use std::list to store pending signals instead of a manually-managed linked list. This is a refactoring. In the existing code, pending signals are kept in a manually-created linked list with "prev" pointers. A new pending signal is thus inserted to the beginning of the list. When consuming, GDB goes until the end of the list, following the "prev" pointers, and processes the final item. With this patch, a new item is added to the end of the list and the item at the front of the list is consumed. In other words, the list elements used to be stored in reverse order; with this patch, they are stored in their order of arrival. This causes a change in the debug messages that print the pending signals. Otherwise, no behavioral change is expected. gdbserver/ChangeLog: 2020-06-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Use std::list to stop pending signal instead of manually-created linked list. * linux-low.h: Include <list>. (struct pending_signal): Move here from linux-low.cc. (struct lwp_info) <pending_signals> <pending_signals_to_report>: Update the type. * linux-low.cc (struct pending_signals): Remove. (linux_process_target::delete_lwp) (linux_process_target::add_lwp) (enqueue_one_deferred_signal) (dequeue_one_deferred_signal) (enqueue_pending_signal) (linux_process_target::resume_one_lwp_throw) (linux_process_target::thread_needs_step_over) (linux_process_target::resume_one_thread) (linux_process_target::proceed_one_lwp): Update the use of pending signal list.
2020-06-22 14:13:48 +02:00
if (sig.signal == WSTOPSIG (*wstat))
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Not requeuing already queued non-RT signal %d"
" for LWP %ld\n",
gdbserver/linux-low: use std::list to store pending signals Use std::list to store pending signals instead of a manually-managed linked list. This is a refactoring. In the existing code, pending signals are kept in a manually-created linked list with "prev" pointers. A new pending signal is thus inserted to the beginning of the list. When consuming, GDB goes until the end of the list, following the "prev" pointers, and processes the final item. With this patch, a new item is added to the end of the list and the item at the front of the list is consumed. In other words, the list elements used to be stored in reverse order; with this patch, they are stored in their order of arrival. This causes a change in the debug messages that print the pending signals. Otherwise, no behavioral change is expected. gdbserver/ChangeLog: 2020-06-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Use std::list to stop pending signal instead of manually-created linked list. * linux-low.h: Include <list>. (struct pending_signal): Move here from linux-low.cc. (struct lwp_info) <pending_signals> <pending_signals_to_report>: Update the type. * linux-low.cc (struct pending_signals): Remove. (linux_process_target::delete_lwp) (linux_process_target::add_lwp) (enqueue_one_deferred_signal) (dequeue_one_deferred_signal) (enqueue_pending_signal) (linux_process_target::resume_one_lwp_throw) (linux_process_target::thread_needs_step_over) (linux_process_target::resume_one_thread) (linux_process_target::proceed_one_lwp): Update the use of pending signal list.
2020-06-22 14:13:48 +02:00
sig.signal,
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
lwpid_of (thread));
return;
}
}
}
gdbserver/linux-low: use std::list to store pending signals Use std::list to store pending signals instead of a manually-managed linked list. This is a refactoring. In the existing code, pending signals are kept in a manually-created linked list with "prev" pointers. A new pending signal is thus inserted to the beginning of the list. When consuming, GDB goes until the end of the list, following the "prev" pointers, and processes the final item. With this patch, a new item is added to the end of the list and the item at the front of the list is consumed. In other words, the list elements used to be stored in reverse order; with this patch, they are stored in their order of arrival. This causes a change in the debug messages that print the pending signals. Otherwise, no behavioral change is expected. gdbserver/ChangeLog: 2020-06-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Use std::list to stop pending signal instead of manually-created linked list. * linux-low.h: Include <list>. (struct pending_signal): Move here from linux-low.cc. (struct lwp_info) <pending_signals> <pending_signals_to_report>: Update the type. * linux-low.cc (struct pending_signals): Remove. (linux_process_target::delete_lwp) (linux_process_target::add_lwp) (enqueue_one_deferred_signal) (dequeue_one_deferred_signal) (enqueue_pending_signal) (linux_process_target::resume_one_lwp_throw) (linux_process_target::thread_needs_step_over) (linux_process_target::resume_one_thread) (linux_process_target::proceed_one_lwp): Update the use of pending signal list.
2020-06-22 14:13:48 +02:00
lwp->pending_signals_to_report.emplace_back (WSTOPSIG (*wstat));
Replace some xmalloc-family functions with XNEW-family ones This patch is part of the make-gdb-buildable-in-C++ effort. The idea is to change some calls to the xmalloc family of functions to calls to the equivalents in the XNEW family. This avoids adding an explicit cast, so it keeps the code a bit more readable. Some of them also map relatively well to a C++ equivalent (XNEW (struct foo) -> new foo), so it will be possible to do scripted replacements if needed. I only changed calls that were obviously allocating memory for one or multiple "objects". Allocation of variable sizes (such as strings or buffer handling) will be for later (and won't use XNEW). - xmalloc (sizeof (struct foo)) -> XNEW (struct foo) - xmalloc (num * sizeof (struct foo)) -> XNEWVEC (struct foo, num) - xcalloc (1, sizeof (struct foo)) -> XCNEW (struct foo) - xcalloc (num, sizeof (struct foo)) -> XCNEWVEC (struct foo, num) - xrealloc (p, num * sizeof (struct foo) -> XRESIZEVEC (struct foo, p, num) - obstack_alloc (ob, sizeof (struct foo)) -> XOBNEW (ob, struct foo) - obstack_alloc (ob, num * sizeof (struct foo)) -> XOBNEWVEC (ob, struct foo, num) - alloca (sizeof (struct foo)) -> XALLOCA (struct foo) - alloca (num * sizeof (struct foo)) -> XALLOCAVEC (struct foo, num) Some instances of xmalloc followed by memset to zero the buffer were replaced by XCNEW or XCNEWVEC. I regtested on x86-64, Ubuntu 14.04, but the patch touches many architecture-specific files. For those I'll have to rely on the buildbot or people complaining that I broke their gdb. gdb/ChangeLog: * aarch64-linux-nat.c (aarch64_add_process): Likewise. * aarch64-tdep.c (aarch64_gdbarch_init): Likewise. * ada-exp.y (write_ambiguous_var): Likewise. * ada-lang.c (resolve_subexp): Likewise. (user_select_syms): Likewise. (assign_aggregate): Likewise. (ada_evaluate_subexp): Likewise. (cache_symbol): Likewise. * addrmap.c (allocate_key): Likewise. (addrmap_create_mutable): Likewise. * aix-thread.c (sync_threadlists): Likewise. * alpha-tdep.c (alpha_push_dummy_call): Likewise. (alpha_gdbarch_init): Likewise. * amd64-windows-tdep.c (amd64_windows_push_arguments): Likewise. * arm-linux-nat.c (arm_linux_add_process): Likewise. * arm-linux-tdep.c (arm_linux_displaced_step_copy_insn): Likewise. * arm-tdep.c (push_stack_item): Likewise. (arm_displaced_step_copy_insn): Likewise. (arm_gdbarch_init): Likewise. (_initialize_arm_tdep): Likewise. * avr-tdep.c (push_stack_item): Likewise. * ax-general.c (new_agent_expr): Likewise. * block.c (block_initialize_namespace): Likewise. * breakpoint.c (alloc_counted_command_line): Likewise. (update_dprintf_command_list): Likewise. (parse_breakpoint_sals): Likewise. (decode_static_tracepoint_spec): Likewise. (until_break_command): Likewise. (clear_command): Likewise. (update_global_location_list): Likewise. (get_breakpoint_objfile_data) Likewise. * btrace.c (ftrace_new_function): Likewise. (btrace_set_insn_history): Likewise. (btrace_set_call_history): Likewise. * buildsym.c (add_symbol_to_list): Likewise. (record_pending_block): Likewise. (start_subfile): Likewise. (start_buildsym_compunit): Likewise. (push_subfile): Likewise. (end_symtab_get_static_block): Likewise. (buildsym_init): Likewise. * cli/cli-cmds.c (source_command): Likewise. * cli/cli-decode.c (add_cmd): Likewise. * cli/cli-script.c (build_command_line): Likewise. (setup_user_args): Likewise. (realloc_body_list): Likewise. (process_next_line): Likewise. (copy_command_lines): Likewise. * cli/cli-setshow.c (do_set_command): Likewise. * coff-pe-read.c (read_pe_exported_syms): Likewise. * coffread.c (coff_locate_sections): Likewise. (coff_symtab_read): Likewise. (coff_read_struct_type): Likewise. * common/cleanups.c (make_my_cleanup2): Likewise. * common/common-exceptions.c (throw_it): Likewise. * common/filestuff.c (make_cleanup_close): Likewise. * common/format.c (parse_format_string): Likewise. * common/queue.h (DEFINE_QUEUE_P): Likewise. * compile/compile-object-load.c (munmap_list_add): Likewise. (compile_object_load): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * compile/compile.c (append_args): Likewise. * corefile.c (specify_exec_file_hook): Likewise. * cp-support.c (make_symbol_overload_list): Likewise. * cris-tdep.c (push_stack_item): Likewise. (cris_gdbarch_init): Likewise. * ctf.c (ctf_trace_file_writer_new): Likewise. * dbxread.c (init_header_files): Likewise. (add_new_header_file): Likewise. (init_bincl_list): Likewise. (dbx_end_psymtab): Likewise. (start_psymtab): Likewise. (dbx_end_psymtab): Likewise. * dcache.c (dcache_init): Likewise. * dictionary.c (dict_create_hashed): Likewise. (dict_create_hashed_expandable): Likewise. (dict_create_linear): Likewise. (dict_create_linear_expandable): Likewise. * dtrace-probe.c (dtrace_process_dof_probe): Likewise. * dummy-frame.c (register_dummy_frame_dtor): Likewise. * dwarf2-frame-tailcall.c (cache_new_ref1): Likewise. * dwarf2-frame.c (dwarf2_build_frame_info): Likewise. (decode_frame_entry_1): Likewise. * dwarf2expr.c (new_dwarf_expr_context): Likewise. * dwarf2loc.c (dwarf2_compile_expr_to_ax): Likewise. * dwarf2read.c (dwarf2_has_info): Likewise. (create_signatured_type_table_from_index): Likewise. (dwarf2_read_index): Likewise. (dw2_get_file_names_reader): Likewise. (create_all_type_units): Likewise. (read_cutu_die_from_dwo): Likewise. (init_tu_and_read_dwo_dies): Likewise. (init_cutu_and_read_dies): Likewise. (create_all_comp_units): Likewise. (queue_comp_unit): Likewise. (inherit_abstract_dies): Likewise. (read_call_site_scope): Likewise. (dwarf2_add_field): Likewise. (dwarf2_add_typedef): Likewise. (dwarf2_add_member_fn): Likewise. (attr_to_dynamic_prop): Likewise. (abbrev_table_alloc_abbrev): Likewise. (abbrev_table_read_table): Likewise. (add_include_dir): Likewise. (add_file_name): Likewise. (dwarf_decode_line_header): Likewise. (dwarf2_const_value_attr): Likewise. (dwarf_alloc_block): Likewise. (parse_macro_definition): Likewise. (set_die_type): Likewise. (write_psymtabs_to_index): Likewise. (create_cus_from_index): Likewise. (dwarf2_create_include_psymtab): Likewise. (process_psymtab_comp_unit_reader): Likewise. (build_type_psymtab_dependencies): Likewise. (read_comp_units_from_section): Likewise. (compute_compunit_symtab_includes): Likewise. (create_dwo_unit_in_dwp_v1): Likewise. (create_dwo_unit_in_dwp_v2): Likewise. (read_func_scope): Likewise. (process_structure_scope): Likewise. (mark_common_block_symbol_computed): Likewise. (load_partial_dies): Likewise. (dwarf2_symbol_mark_computed): Likewise. * elfread.c (elf_symfile_segments): Likewise. (elf_read_minimal_symbols): Likewise. * environ.c (make_environ): Likewise. * eval.c (evaluate_subexp_standard): Likewise. * event-loop.c (create_file_handler): Likewise. (create_async_signal_handler): Likewise. (create_async_event_handler): Likewise. (create_timer): Likewise. * exec.c (build_section_table): Likewise. * fbsd-nat.c (fbsd_remember_child): Likewise. * fork-child.c (fork_inferior): Likewise. * frv-tdep.c (new_variant): Likewise. * gdbarch.sh (gdbarch_alloc): Likewise. (append_name): Likewise. * gdbtypes.c (rank_function): Likewise. (copy_type_recursive): Likewise. (add_dyn_prop): Likewise. * gnu-nat.c (make_proc): Likewise. (make_inf): Likewise. (gnu_write_inferior): Likewise. * gnu-v3-abi.c (build_gdb_vtable_type): Likewise. (build_std_type_info_type): Likewise. * guile/scm-param.c (compute_enum_list): Likewise. * guile/scm-utils.c (gdbscm_parse_function_args): Likewise. * guile/scm-value.c (gdbscm_value_call): Likewise. * h8300-tdep.c (h8300_gdbarch_init): Likewise. * hppa-tdep.c (hppa_init_objfile_priv_data): Likewise. (read_unwind_info): Likewise. * ia64-tdep.c (ia64_gdbarch_init): Likewise. * infcall.c (dummy_frame_context_saver_setup): Likewise. (call_function_by_hand_dummy): Likewise. * infcmd.c (step_once): Likewise. (finish_forward): Likewise. (attach_command): Likewise. (notice_new_inferior): Likewise. * inferior.c (add_inferior_silent): Likewise. * infrun.c (add_displaced_stepping_state): Likewise. (save_infcall_control_state): Likewise. (save_inferior_ptid): Likewise. (_initialize_infrun): Likewise. * jit.c (bfd_open_from_target_memory): Likewise. (jit_gdbarch_data_init): Likewise. * language.c (add_language): Likewise. * linespec.c (decode_line_2): Likewise. * linux-nat.c (add_to_pid_list): Likewise. (add_initial_lwp): Likewise. * linux-thread-db.c (add_thread_db_info): Likewise. (record_thread): Likewise. (info_auto_load_libthread_db): Likewise. * m32c-tdep.c (m32c_gdbarch_init): Likewise. * m68hc11-tdep.c (m68hc11_gdbarch_init): Likewise. * m68k-tdep.c (m68k_gdbarch_init): Likewise. * m88k-tdep.c (m88k_analyze_prologue): Likewise. * macrocmd.c (macro_define_command): Likewise. * macroexp.c (gather_arguments): Likewise. * macroscope.c (sal_macro_scope): Likewise. * macrotab.c (new_macro_table): Likewise. * mdebugread.c (push_parse_stack): Likewise. (parse_partial_symbols): Likewise. (parse_symbol): Likewise. (psymtab_to_symtab_1): Likewise. (new_block): Likewise. (new_psymtab): Likewise. (mdebug_build_psymtabs): Likewise. (add_pending): Likewise. (elfmdebug_build_psymtabs): Likewise. * mep-tdep.c (mep_gdbarch_init): Likewise. * mi/mi-main.c (mi_execute_command): Likewise. * mi/mi-parse.c (mi_parse_argv): Likewise. * minidebug.c (lzma_open): Likewise. * minsyms.c (terminate_minimal_symbol_table): Likewise. * mips-linux-nat.c (mips_linux_insert_watchpoint): Likewise. * mips-tdep.c (mips_gdbarch_init): Likewise. * mn10300-tdep.c (mn10300_gdbarch_init): Likewise. * msp430-tdep.c (msp430_gdbarch_init): Likewise. * mt-tdep.c (mt_registers_info): Likewise. * nat/aarch64-linux.c (aarch64_linux_new_thread): Likewise. * nat/linux-btrace.c (linux_enable_bts): Likewise. (linux_enable_pt): Likewise. * nat/linux-osdata.c (linux_xfer_osdata_processes): Likewise. (linux_xfer_osdata_processgroups): Likewise. * nios2-tdep.c (nios2_gdbarch_init): Likewise. * nto-procfs.c (procfs_meminfo): Likewise. * objc-lang.c (start_msglist): Likewise. (selectors_info): Likewise. (classes_info): Likewise. (find_methods): Likewise. * objfiles.c (allocate_objfile): Likewise. (update_section_map): Likewise. * osabi.c (gdbarch_register_osabi): Likewise. (gdbarch_register_osabi_sniffer): Likewise. * parse.c (start_arglist): Likewise. * ppc-linux-nat.c (hwdebug_find_thread_points_by_tid): Likewise. (hwdebug_insert_point): Likewise. * printcmd.c (display_command): Likewise. (ui_printf): Likewise. * procfs.c (create_procinfo): Likewise. (load_syscalls): Likewise. (proc_get_LDT_entry): Likewise. (proc_update_threads): Likewise. * prologue-value.c (make_pv_area): Likewise. (pv_area_store): Likewise. * psymtab.c (extend_psymbol_list): Likewise. (init_psymbol_list): Likewise. (allocate_psymtab): Likewise. * python/py-inferior.c (add_thread_object): Likewise. * python/py-param.c (compute_enum_values): Likewise. * python/py-value.c (valpy_call): Likewise. * python/py-varobj.c (py_varobj_iter_next): Likewise. * python/python.c (ensure_python_env): Likewise. * record-btrace.c (record_btrace_start_replaying): Likewise. * record-full.c (record_full_reg_alloc): Likewise. (record_full_mem_alloc): Likewise. (record_full_end_alloc): Likewise. (record_full_core_xfer_partial): Likewise. * regcache.c (get_thread_arch_aspace_regcache): Likewise. * remote-fileio.c (remote_fileio_init_fd_map): Likewise. * remote-notif.c (remote_notif_state_allocate): Likewise. * remote.c (demand_private_info): Likewise. (remote_notif_stop_alloc_reply): Likewise. (remote_enable_btrace): Likewise. * reverse.c (save_bookmark_command): Likewise. * rl78-tdep.c (rl78_gdbarch_init): Likewise. * rx-tdep.c (rx_gdbarch_init): Likewise. * s390-linux-nat.c (s390_insert_watchpoint): Likewise. * ser-go32.c (dos_get_tty_state): Likewise. (dos_copy_tty_state): Likewise. * ser-mingw.c (ser_windows_open): Likewise. (ser_console_wait_handle): Likewise. (ser_console_get_tty_state): Likewise. (make_pipe_state): Likewise. (net_windows_open): Likewise. * ser-unix.c (hardwire_get_tty_state): Likewise. (hardwire_copy_tty_state): Likewise. * solib-aix.c (solib_aix_new_lm_info): Likewise. * solib-dsbt.c (dsbt_current_sos): Likewise. (dsbt_relocate_main_executable): Likewise. * solib-frv.c (frv_current_sos): Likewise. (frv_relocate_main_executable): Likewise. * solib-spu.c (spu_bfd_fopen): Likewise. * solib-svr4.c (lm_info_read): Likewise. (svr4_copy_library_list): Likewise. (svr4_default_sos): Likewise. * source.c (find_source_lines): Likewise. (line_info): Likewise. (add_substitute_path_rule): Likewise. * spu-linux-nat.c (spu_bfd_open): Likewise. * spu-tdep.c (info_spu_dma_cmdlist): Likewise. * stabsread.c (dbx_lookup_type): Likewise. (read_type): Likewise. (read_member_functions): Likewise. (read_struct_fields): Likewise. (read_baseclasses): Likewise. (read_args): Likewise. (_initialize_stabsread): Likewise. * stack.c (func_command): Likewise. * stap-probe.c (handle_stap_probe): Likewise. * symfile.c (addrs_section_sort): Likewise. (addr_info_make_relative): Likewise. (load_section_callback): Likewise. (add_symbol_file_command): Likewise. (init_filename_language_table): Likewise. * symtab.c (create_filename_seen_cache): Likewise. (sort_search_symbols_remove_dups): Likewise. (search_symbols): Likewise. * target.c (make_cleanup_restore_target_terminal): Likewise. * thread.c (new_thread): Likewise. (enable_thread_stack_temporaries): Likewise. (make_cleanup_restore_current_thread): Likewise. (thread_apply_all_command): Likewise. * tic6x-tdep.c (tic6x_gdbarch_init): Likewise. * top.c (gdb_readline_wrapper): Likewise. * tracefile-tfile.c (tfile_trace_file_writer_new): Likewise. * tracepoint.c (trace_find_line_command): Likewise. (all_tracepoint_actions_and_cleanup): Likewise. (make_cleanup_restore_current_traceframe): Likewise. (get_uploaded_tp): Likewise. (get_uploaded_tsv): Likewise. * tui/tui-data.c (tui_alloc_generic_win_info): Likewise. (tui_alloc_win_info): Likewise. (tui_alloc_content): Likewise. (tui_add_content_elements): Likewise. * tui/tui-disasm.c (tui_find_disassembly_address): Likewise. (tui_set_disassem_content): Likewise. * ui-file.c (ui_file_new): Likewise. (stdio_file_new): Likewise. (tee_file_new): Likewise. * utils.c (make_cleanup_restore_integer): Likewise. (add_internal_problem_command): Likewise. * v850-tdep.c (v850_gdbarch_init): Likewise. * valops.c (find_oload_champ): Likewise. * value.c (allocate_value_lazy): Likewise. (record_latest_value): Likewise. (create_internalvar): Likewise. * varobj.c (install_variable): Likewise. (new_variable): Likewise. (new_root_variable): Likewise. (cppush): Likewise. (_initialize_varobj): Likewise. * windows-nat.c (windows_make_so): Likewise. * x86-nat.c (x86_add_process): Likewise. * xcoffread.c (arrange_linetable): Likewise. (allocate_include_entry): Likewise. (process_linenos): Likewise. (SYMBOL_DUP): Likewise. (xcoff_start_psymtab): Likewise. (xcoff_end_psymtab): Likewise. * xml-support.c (gdb_xml_parse_attr_ulongest): Likewise. * xtensa-tdep.c (xtensa_register_type): Likewise. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. gdb/gdbserver/ChangeLog: * ax.c (gdb_parse_agent_expr): Likewise. (compile_bytecodes): Likewise. * dll.c (loaded_dll): Likewise. * event-loop.c (append_callback_event): Likewise. (create_file_handler): Likewise. (create_file_event): Likewise. * hostio.c (handle_open): Likewise. * inferiors.c (add_thread): Likewise. (add_process): Likewise. * linux-aarch64-low.c (aarch64_linux_new_process): Likewise. * linux-arm-low.c (arm_new_process): Likewise. (arm_new_thread): Likewise. * linux-low.c (add_to_pid_list): Likewise. (linux_add_process): Likewise. (handle_extended_wait): Likewise. (add_lwp): Likewise. (enqueue_one_deferred_signal): Likewise. (enqueue_pending_signal): Likewise. (linux_resume_one_lwp_throw): Likewise. (linux_resume_one_thread): Likewise. (linux_read_memory): Likewise. (linux_write_memory): Likewise. * linux-mips-low.c (mips_linux_new_process): Likewise. (mips_linux_new_thread): Likewise. (mips_add_watchpoint): Likewise. * linux-x86-low.c (initialize_low_arch): Likewise. * lynx-low.c (lynx_add_process): Likewise. * mem-break.c (set_raw_breakpoint_at): Likewise. (set_breakpoint): Likewise. (add_condition_to_breakpoint): Likewise. (add_commands_to_breakpoint): Likewise. (clone_agent_expr): Likewise. (clone_one_breakpoint): Likewise. * regcache.c (new_register_cache): Likewise. * remote-utils.c (look_up_one_symbol): Likewise. * server.c (queue_stop_reply): Likewise. (start_inferior): Likewise. (queue_stop_reply_callback): Likewise. (handle_target_event): Likewise. * spu-low.c (fetch_ppc_memory): Likewise. (store_ppc_memory): Likewise. * target.c (set_target_ops): Likewise. * thread-db.c (thread_db_load_search): Likewise. (try_thread_db_load_1): Likewise. * tracepoint.c (add_tracepoint): Likewise. (add_tracepoint_action): Likewise. (create_trace_state_variable): Likewise. (cmd_qtdpsrc): Likewise. (cmd_qtro): Likewise. (add_while_stepping_state): Likewise. * win32-low.c (child_add_thread): Likewise. (get_image_name): Likewise.
2015-08-26 23:16:07 +02:00
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
ptrace (PTRACE_GETSIGINFO, lwpid_of (thread), (PTRACE_TYPE_ARG3) 0,
gdbserver/linux-low: use std::list to store pending signals Use std::list to store pending signals instead of a manually-managed linked list. This is a refactoring. In the existing code, pending signals are kept in a manually-created linked list with "prev" pointers. A new pending signal is thus inserted to the beginning of the list. When consuming, GDB goes until the end of the list, following the "prev" pointers, and processes the final item. With this patch, a new item is added to the end of the list and the item at the front of the list is consumed. In other words, the list elements used to be stored in reverse order; with this patch, they are stored in their order of arrival. This causes a change in the debug messages that print the pending signals. Otherwise, no behavioral change is expected. gdbserver/ChangeLog: 2020-06-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Use std::list to stop pending signal instead of manually-created linked list. * linux-low.h: Include <list>. (struct pending_signal): Move here from linux-low.cc. (struct lwp_info) <pending_signals> <pending_signals_to_report>: Update the type. * linux-low.cc (struct pending_signals): Remove. (linux_process_target::delete_lwp) (linux_process_target::add_lwp) (enqueue_one_deferred_signal) (dequeue_one_deferred_signal) (enqueue_pending_signal) (linux_process_target::resume_one_lwp_throw) (linux_process_target::thread_needs_step_over) (linux_process_target::resume_one_thread) (linux_process_target::proceed_one_lwp): Update the use of pending signal list.
2020-06-22 14:13:48 +02:00
&lwp->pending_signals_to_report.back ().info);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
}
/* Dequeue one signal from the "signals to report later when out of
the jump pad" list. */
static int
dequeue_one_deferred_signal (struct lwp_info *lwp, int *wstat)
{
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
struct thread_info *thread = get_lwp_thread (lwp);
gdbserver/linux-low: use std::list to store pending signals Use std::list to store pending signals instead of a manually-managed linked list. This is a refactoring. In the existing code, pending signals are kept in a manually-created linked list with "prev" pointers. A new pending signal is thus inserted to the beginning of the list. When consuming, GDB goes until the end of the list, following the "prev" pointers, and processes the final item. With this patch, a new item is added to the end of the list and the item at the front of the list is consumed. In other words, the list elements used to be stored in reverse order; with this patch, they are stored in their order of arrival. This causes a change in the debug messages that print the pending signals. Otherwise, no behavioral change is expected. gdbserver/ChangeLog: 2020-06-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Use std::list to stop pending signal instead of manually-created linked list. * linux-low.h: Include <list>. (struct pending_signal): Move here from linux-low.cc. (struct lwp_info) <pending_signals> <pending_signals_to_report>: Update the type. * linux-low.cc (struct pending_signals): Remove. (linux_process_target::delete_lwp) (linux_process_target::add_lwp) (enqueue_one_deferred_signal) (dequeue_one_deferred_signal) (enqueue_pending_signal) (linux_process_target::resume_one_lwp_throw) (linux_process_target::thread_needs_step_over) (linux_process_target::resume_one_thread) (linux_process_target::proceed_one_lwp): Update the use of pending signal list.
2020-06-22 14:13:48 +02:00
if (!lwp->pending_signals_to_report.empty ())
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
{
gdbserver/linux-low: use std::list to store pending signals Use std::list to store pending signals instead of a manually-managed linked list. This is a refactoring. In the existing code, pending signals are kept in a manually-created linked list with "prev" pointers. A new pending signal is thus inserted to the beginning of the list. When consuming, GDB goes until the end of the list, following the "prev" pointers, and processes the final item. With this patch, a new item is added to the end of the list and the item at the front of the list is consumed. In other words, the list elements used to be stored in reverse order; with this patch, they are stored in their order of arrival. This causes a change in the debug messages that print the pending signals. Otherwise, no behavioral change is expected. gdbserver/ChangeLog: 2020-06-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Use std::list to stop pending signal instead of manually-created linked list. * linux-low.h: Include <list>. (struct pending_signal): Move here from linux-low.cc. (struct lwp_info) <pending_signals> <pending_signals_to_report>: Update the type. * linux-low.cc (struct pending_signals): Remove. (linux_process_target::delete_lwp) (linux_process_target::add_lwp) (enqueue_one_deferred_signal) (dequeue_one_deferred_signal) (enqueue_pending_signal) (linux_process_target::resume_one_lwp_throw) (linux_process_target::thread_needs_step_over) (linux_process_target::resume_one_thread) (linux_process_target::proceed_one_lwp): Update the use of pending signal list.
2020-06-22 14:13:48 +02:00
const pending_signal &p_sig = lwp->pending_signals_to_report.front ();
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
gdbserver/linux-low: use std::list to store pending signals Use std::list to store pending signals instead of a manually-managed linked list. This is a refactoring. In the existing code, pending signals are kept in a manually-created linked list with "prev" pointers. A new pending signal is thus inserted to the beginning of the list. When consuming, GDB goes until the end of the list, following the "prev" pointers, and processes the final item. With this patch, a new item is added to the end of the list and the item at the front of the list is consumed. In other words, the list elements used to be stored in reverse order; with this patch, they are stored in their order of arrival. This causes a change in the debug messages that print the pending signals. Otherwise, no behavioral change is expected. gdbserver/ChangeLog: 2020-06-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Use std::list to stop pending signal instead of manually-created linked list. * linux-low.h: Include <list>. (struct pending_signal): Move here from linux-low.cc. (struct lwp_info) <pending_signals> <pending_signals_to_report>: Update the type. * linux-low.cc (struct pending_signals): Remove. (linux_process_target::delete_lwp) (linux_process_target::add_lwp) (enqueue_one_deferred_signal) (dequeue_one_deferred_signal) (enqueue_pending_signal) (linux_process_target::resume_one_lwp_throw) (linux_process_target::thread_needs_step_over) (linux_process_target::resume_one_thread) (linux_process_target::proceed_one_lwp): Update the use of pending signal list.
2020-06-22 14:13:48 +02:00
*wstat = W_STOPCODE (p_sig.signal);
if (p_sig.info.si_signo != 0)
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
ptrace (PTRACE_SETSIGINFO, lwpid_of (thread), (PTRACE_TYPE_ARG3) 0,
gdbserver/linux-low: use std::list to store pending signals Use std::list to store pending signals instead of a manually-managed linked list. This is a refactoring. In the existing code, pending signals are kept in a manually-created linked list with "prev" pointers. A new pending signal is thus inserted to the beginning of the list. When consuming, GDB goes until the end of the list, following the "prev" pointers, and processes the final item. With this patch, a new item is added to the end of the list and the item at the front of the list is consumed. In other words, the list elements used to be stored in reverse order; with this patch, they are stored in their order of arrival. This causes a change in the debug messages that print the pending signals. Otherwise, no behavioral change is expected. gdbserver/ChangeLog: 2020-06-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Use std::list to stop pending signal instead of manually-created linked list. * linux-low.h: Include <list>. (struct pending_signal): Move here from linux-low.cc. (struct lwp_info) <pending_signals> <pending_signals_to_report>: Update the type. * linux-low.cc (struct pending_signals): Remove. (linux_process_target::delete_lwp) (linux_process_target::add_lwp) (enqueue_one_deferred_signal) (dequeue_one_deferred_signal) (enqueue_pending_signal) (linux_process_target::resume_one_lwp_throw) (linux_process_target::thread_needs_step_over) (linux_process_target::resume_one_thread) (linux_process_target::proceed_one_lwp): Update the use of pending signal list.
2020-06-22 14:13:48 +02:00
&p_sig.info);
lwp->pending_signals_to_report.pop_front ();
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Reporting deferred signal %d for LWP %ld.\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
WSTOPSIG (*wstat), lwpid_of (thread));
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
if (debug_threads)
{
gdbserver/linux-low: use std::list to store pending signals Use std::list to store pending signals instead of a manually-managed linked list. This is a refactoring. In the existing code, pending signals are kept in a manually-created linked list with "prev" pointers. A new pending signal is thus inserted to the beginning of the list. When consuming, GDB goes until the end of the list, following the "prev" pointers, and processes the final item. With this patch, a new item is added to the end of the list and the item at the front of the list is consumed. In other words, the list elements used to be stored in reverse order; with this patch, they are stored in their order of arrival. This causes a change in the debug messages that print the pending signals. Otherwise, no behavioral change is expected. gdbserver/ChangeLog: 2020-06-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Use std::list to stop pending signal instead of manually-created linked list. * linux-low.h: Include <list>. (struct pending_signal): Move here from linux-low.cc. (struct lwp_info) <pending_signals> <pending_signals_to_report>: Update the type. * linux-low.cc (struct pending_signals): Remove. (linux_process_target::delete_lwp) (linux_process_target::add_lwp) (enqueue_one_deferred_signal) (dequeue_one_deferred_signal) (enqueue_pending_signal) (linux_process_target::resume_one_lwp_throw) (linux_process_target::thread_needs_step_over) (linux_process_target::resume_one_thread) (linux_process_target::proceed_one_lwp): Update the use of pending signal list.
2020-06-22 14:13:48 +02:00
for (const auto &sig : lwp->pending_signals_to_report)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf (" Still queued %d\n",
gdbserver/linux-low: use std::list to store pending signals Use std::list to store pending signals instead of a manually-managed linked list. This is a refactoring. In the existing code, pending signals are kept in a manually-created linked list with "prev" pointers. A new pending signal is thus inserted to the beginning of the list. When consuming, GDB goes until the end of the list, following the "prev" pointers, and processes the final item. With this patch, a new item is added to the end of the list and the item at the front of the list is consumed. In other words, the list elements used to be stored in reverse order; with this patch, they are stored in their order of arrival. This causes a change in the debug messages that print the pending signals. Otherwise, no behavioral change is expected. gdbserver/ChangeLog: 2020-06-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Use std::list to stop pending signal instead of manually-created linked list. * linux-low.h: Include <list>. (struct pending_signal): Move here from linux-low.cc. (struct lwp_info) <pending_signals> <pending_signals_to_report>: Update the type. * linux-low.cc (struct pending_signals): Remove. (linux_process_target::delete_lwp) (linux_process_target::add_lwp) (enqueue_one_deferred_signal) (dequeue_one_deferred_signal) (enqueue_pending_signal) (linux_process_target::resume_one_lwp_throw) (linux_process_target::thread_needs_step_over) (linux_process_target::resume_one_thread) (linux_process_target::proceed_one_lwp): Update the use of pending signal list.
2020-06-22 14:13:48 +02:00
sig.signal);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf (" (no more queued signals)\n");
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
}
return 1;
}
return 0;
}
gdbserver/linux-low: turn watchpoint ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'stopped_by_watchpoint' and 'stopped_data_address' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <check_stopped_by_watchpoint> <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. * linux-low.cc (check_stopped_by_watchpoint): Turn into... (linux_process_target::check_stopped_by_watchpoint): ...this. (linux_process_target::low_stopped_by_watchpoint): Define. (linux_process_target::low_stopped_data_address): Define. * linux-x86-low.cc (class x86_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (x86_stopped_by_watchpoint): Turn into... (x86_target::low_stopped_by_watchpoint): ...this. (x86_stopped_data_address): Turn into... (x86_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (aarch64_stopped_by_watchpoint): Turn into... (aarch64_target::low_stopped_by_watchpoint): ...this. (aarch64_stopped_data_address): Turn into... (aarch64_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (arm_stopped_by_watchpoint): Turn into... (arm_target::low_stopped_by_watchpoint): ...this. (arm_stopped_data_address): Turn into... (arm_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (cris_stopped_by_watchpoint): Turn into... (crisv32_target::low_stopped_by_watchpoint): ...this. (cris_stopped_data_address): Turn into... (crisv32_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (mips_stopped_by_watchpoint): Turn into... (mips_target::low_stopped_by_watchpoint): ...this. (mips_stopped_data_address): Turn into... (mips_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-sparc-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:27 +02:00
bool
linux_process_target::check_stopped_by_watchpoint (lwp_info *child)
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
{
gdbserver/linux-low: turn watchpoint ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'stopped_by_watchpoint' and 'stopped_data_address' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <check_stopped_by_watchpoint> <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. * linux-low.cc (check_stopped_by_watchpoint): Turn into... (linux_process_target::check_stopped_by_watchpoint): ...this. (linux_process_target::low_stopped_by_watchpoint): Define. (linux_process_target::low_stopped_data_address): Define. * linux-x86-low.cc (class x86_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (x86_stopped_by_watchpoint): Turn into... (x86_target::low_stopped_by_watchpoint): ...this. (x86_stopped_data_address): Turn into... (x86_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (aarch64_stopped_by_watchpoint): Turn into... (aarch64_target::low_stopped_by_watchpoint): ...this. (aarch64_stopped_data_address): Turn into... (aarch64_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (arm_stopped_by_watchpoint): Turn into... (arm_target::low_stopped_by_watchpoint): ...this. (arm_stopped_data_address): Turn into... (arm_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (cris_stopped_by_watchpoint): Turn into... (crisv32_target::low_stopped_by_watchpoint): ...this. (cris_stopped_data_address): Turn into... (crisv32_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (mips_stopped_by_watchpoint): Turn into... (mips_target::low_stopped_by_watchpoint): ...this. (mips_stopped_data_address): Turn into... (mips_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-sparc-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:27 +02:00
struct thread_info *saved_thread = current_thread;
current_thread = get_lwp_thread (child);
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
gdbserver/linux-low: turn watchpoint ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'stopped_by_watchpoint' and 'stopped_data_address' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <check_stopped_by_watchpoint> <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. * linux-low.cc (check_stopped_by_watchpoint): Turn into... (linux_process_target::check_stopped_by_watchpoint): ...this. (linux_process_target::low_stopped_by_watchpoint): Define. (linux_process_target::low_stopped_data_address): Define. * linux-x86-low.cc (class x86_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (x86_stopped_by_watchpoint): Turn into... (x86_target::low_stopped_by_watchpoint): ...this. (x86_stopped_data_address): Turn into... (x86_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (aarch64_stopped_by_watchpoint): Turn into... (aarch64_target::low_stopped_by_watchpoint): ...this. (aarch64_stopped_data_address): Turn into... (aarch64_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (arm_stopped_by_watchpoint): Turn into... (arm_target::low_stopped_by_watchpoint): ...this. (arm_stopped_data_address): Turn into... (arm_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (cris_stopped_by_watchpoint): Turn into... (crisv32_target::low_stopped_by_watchpoint): ...this. (cris_stopped_data_address): Turn into... (crisv32_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (mips_stopped_by_watchpoint): Turn into... (mips_target::low_stopped_by_watchpoint): ...this. (mips_stopped_data_address): Turn into... (mips_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-sparc-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:27 +02:00
if (low_stopped_by_watchpoint ())
{
child->stop_reason = TARGET_STOPPED_BY_WATCHPOINT;
child->stopped_data_address = low_stopped_data_address ();
}
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
gdbserver/linux-low: turn watchpoint ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'stopped_by_watchpoint' and 'stopped_data_address' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <check_stopped_by_watchpoint> <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. * linux-low.cc (check_stopped_by_watchpoint): Turn into... (linux_process_target::check_stopped_by_watchpoint): ...this. (linux_process_target::low_stopped_by_watchpoint): Define. (linux_process_target::low_stopped_data_address): Define. * linux-x86-low.cc (class x86_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (x86_stopped_by_watchpoint): Turn into... (x86_target::low_stopped_by_watchpoint): ...this. (x86_stopped_data_address): Turn into... (x86_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (aarch64_stopped_by_watchpoint): Turn into... (aarch64_target::low_stopped_by_watchpoint): ...this. (aarch64_stopped_data_address): Turn into... (aarch64_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (arm_stopped_by_watchpoint): Turn into... (arm_target::low_stopped_by_watchpoint): ...this. (arm_stopped_data_address): Turn into... (arm_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (cris_stopped_by_watchpoint): Turn into... (crisv32_target::low_stopped_by_watchpoint): ...this. (cris_stopped_data_address): Turn into... (crisv32_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (mips_stopped_by_watchpoint): Turn into... (mips_target::low_stopped_by_watchpoint): ...this. (mips_stopped_data_address): Turn into... (mips_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-sparc-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:27 +02:00
current_thread = saved_thread;
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
gdbserver/linux-low: turn watchpoint ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'stopped_by_watchpoint' and 'stopped_data_address' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <check_stopped_by_watchpoint> <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. * linux-low.cc (check_stopped_by_watchpoint): Turn into... (linux_process_target::check_stopped_by_watchpoint): ...this. (linux_process_target::low_stopped_by_watchpoint): Define. (linux_process_target::low_stopped_data_address): Define. * linux-x86-low.cc (class x86_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (x86_stopped_by_watchpoint): Turn into... (x86_target::low_stopped_by_watchpoint): ...this. (x86_stopped_data_address): Turn into... (x86_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (aarch64_stopped_by_watchpoint): Turn into... (aarch64_target::low_stopped_by_watchpoint): ...this. (aarch64_stopped_data_address): Turn into... (aarch64_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (arm_stopped_by_watchpoint): Turn into... (arm_target::low_stopped_by_watchpoint): ...this. (arm_stopped_data_address): Turn into... (arm_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (cris_stopped_by_watchpoint): Turn into... (crisv32_target::low_stopped_by_watchpoint): ...this. (cris_stopped_data_address): Turn into... (crisv32_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (mips_stopped_by_watchpoint): Turn into... (mips_target::low_stopped_by_watchpoint): ...this. (mips_stopped_data_address): Turn into... (mips_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-sparc-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:27 +02:00
return child->stop_reason == TARGET_STOPPED_BY_WATCHPOINT;
}
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
gdbserver/linux-low: turn watchpoint ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'stopped_by_watchpoint' and 'stopped_data_address' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <check_stopped_by_watchpoint> <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. * linux-low.cc (check_stopped_by_watchpoint): Turn into... (linux_process_target::check_stopped_by_watchpoint): ...this. (linux_process_target::low_stopped_by_watchpoint): Define. (linux_process_target::low_stopped_data_address): Define. * linux-x86-low.cc (class x86_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (x86_stopped_by_watchpoint): Turn into... (x86_target::low_stopped_by_watchpoint): ...this. (x86_stopped_data_address): Turn into... (x86_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (aarch64_stopped_by_watchpoint): Turn into... (aarch64_target::low_stopped_by_watchpoint): ...this. (aarch64_stopped_data_address): Turn into... (aarch64_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (arm_stopped_by_watchpoint): Turn into... (arm_target::low_stopped_by_watchpoint): ...this. (arm_stopped_data_address): Turn into... (arm_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (cris_stopped_by_watchpoint): Turn into... (crisv32_target::low_stopped_by_watchpoint): ...this. (cris_stopped_data_address): Turn into... (crisv32_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (mips_stopped_by_watchpoint): Turn into... (mips_target::low_stopped_by_watchpoint): ...this. (mips_stopped_data_address): Turn into... (mips_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-sparc-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:27 +02:00
bool
linux_process_target::low_stopped_by_watchpoint ()
{
return false;
}
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
gdbserver/linux-low: turn watchpoint ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'stopped_by_watchpoint' and 'stopped_data_address' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <check_stopped_by_watchpoint> <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. * linux-low.cc (check_stopped_by_watchpoint): Turn into... (linux_process_target::check_stopped_by_watchpoint): ...this. (linux_process_target::low_stopped_by_watchpoint): Define. (linux_process_target::low_stopped_data_address): Define. * linux-x86-low.cc (class x86_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (x86_stopped_by_watchpoint): Turn into... (x86_target::low_stopped_by_watchpoint): ...this. (x86_stopped_data_address): Turn into... (x86_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (aarch64_stopped_by_watchpoint): Turn into... (aarch64_target::low_stopped_by_watchpoint): ...this. (aarch64_stopped_data_address): Turn into... (aarch64_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (arm_stopped_by_watchpoint): Turn into... (arm_target::low_stopped_by_watchpoint): ...this. (arm_stopped_data_address): Turn into... (arm_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (cris_stopped_by_watchpoint): Turn into... (crisv32_target::low_stopped_by_watchpoint): ...this. (cris_stopped_data_address): Turn into... (crisv32_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_stopped_by_watchpoint> <low_stopped_data_address>: Declare. (mips_stopped_by_watchpoint): Turn into... (mips_target::low_stopped_by_watchpoint): ...this. (mips_stopped_data_address): Turn into... (mips_target::low_stopped_data_address): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-sparc-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:27 +02:00
CORE_ADDR
linux_process_target::low_stopped_data_address ()
{
return 0;
Honour SIGILL and SIGSEGV in cancel breakpoint and event lwp selection I see the following fail on arm-none-linux-gnueabi testing, (gdb) continue^M Continuing.^M ^M Program received signal SIGILL, Illegal instruction.^M [Switching to Thread 1003]^M handler (signo=10) at /scratch/yqi/arm-none-linux-gnueabi/src/gdb-trunk/gdb/testsuite/gdb.threads/sigstep-threads.c:33^M 33 tgkill (getpid (), gettid (), SIGUSR1); /* step-2 */^M (gdb) FAIL: gdb.threads/sigstep-threads.exp: continue the cause is that GDBserver doesn't cancel the breakpoint if the stop signal is SIGILL. The kernel used here is a little old, 2.6.x, and doesn't translate SIGILL to SIGTRAP when program hits breakpoint instruction (which is an illegal instruction actually). GDB and GDBserver can translate SIGILL to SIGTRAP under certain circumstance, so it is not a problem here. See gdbserver/linux-low.c:linux_wait_1 /* If this event was not handled before, and is not a SIGTRAP, we report it. SIGILL and SIGSEGV are also treated as traps in case a breakpoint is inserted at the current PC. If this target does not support internal breakpoints at all, we also report the SIGTRAP without further processing; it's of no concern to us. */ maybe_internal_trap = (supports_breakpoints () && (WSTOPSIG (w) == SIGTRAP || ((WSTOPSIG (w) == SIGILL || WSTOPSIG (w) == SIGSEGV) && (*the_low_target.breakpoint_at) (event_child->stop_pc)))); However, SIGILL and SIGSEGV is not considered when cancelling breakpoint, which causes the fail above. That is, when GDB is doing software single step on address ADDR, both thread A and thread B hits the software single step breakpoint, and get SIGILL. GDB selects the event from thread A, removes the software single step breakpoint, and resume the program. The event (SIGILL) from thread B is reported to GDB, but GDB doesn't regard this SIGILL as SIGTRAP, because the breakpoint on address ADDR was removed, so GDB reports "Program received signal SIGILL". The patch is to allow calling cancel_breakpoint if the signal is SIGILL and SIGSEGV. This patch fixes the fail above. Likewise, event lwp selection should honour SIGILL and SIGSEGV too. gdb/gdbserver: 2014-09-23 Yao Qi <yao@codesourcery.com> * linux-low.c (lp_status_maybe_breakpoint): New function. (linux_low_filter_event): Call lp_status_maybe_breakpoint. (count_events_callback): Likewise. (select_event_lwp_callback): Likewise. (cancel_breakpoints_callback): Likewise.
2014-09-12 07:35:11 +02:00
}
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
/* Return the ptrace options that we want to try to enable. */
static int
linux_low_ptrace_options (int attached)
{
client_state &cs = get_client_state ();
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
int options = 0;
if (!attached)
options |= PTRACE_O_EXITKILL;
if (cs.report_fork_events)
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
options |= PTRACE_O_TRACEFORK;
if (cs.report_vfork_events)
2015-05-12 18:52:45 +02:00
options |= (PTRACE_O_TRACEVFORK | PTRACE_O_TRACEVFORKDONE);
if (cs.report_exec_events)
Extended-remote follow-exec This patch implements support for exec events on extended-remote Linux targets. Follow-exec-mode and rerun behave as expected. Catchpoints and test updates are implemented in subsequent patches. This patch was derived from a patch posted last October: https://sourceware.org/ml/gdb-patches/2014-10/msg00877.html. It was originally based on some work done by Luis Machado in 2013. IMPLEMENTATION ---------------- Exec events are enabled via ptrace options. When an exec event is detected by gdbserver, the existing process data, along with all its associated lwp and thread data, is deleted and replaced by data for a new single-threaded process. The new process data is initialized with the appropriate parts of the state of the execing process. This approach takes care of several potential pitfalls, including: * deleting the data for an execing non-leader thread before any wait/sigsuspend occurs * correctly initializing the architecture of the execed process We then report the exec event using a new RSP stop reason, "exec". When GDB receives an "exec" event, it saves the status in the event structure's target_waitstatus field, like what is done for remote fork events. Because the original and execed programs may have different architectures, we skip parsing the section of the stop reply packet that contains register data. The register data will be retrieved later after the inferior's architecture has been set up by infrun.c:follow_exec. At that point the exec event is handled by the existing event handling in GDB. However, a few changes were necessary so that infrun.c:follow_exec could accommodate the remote target. * Where follow-exec-mode "new" is handled, we now call add_inferior_with_spaces instead of add_inferior with separate calls to set up the program and address spaces. The motivation for this is that add_inferior_with_spaces also sets up the initial architecture for the inferior, which is needed later by target_find_description when it calls target_gdbarch. * We call a new target function, target_follow_exec. This function allows us to store the execd_pathname in the inferior, instead of using the static string remote_exec_file from remote.c. The static string didn't work for follow-exec-mode "new", since once you switched to the execed program, the original remote exec-file was lost. The execd_pathname is now stored in the inferior's program space as a REGISTRY field. All of the requisite mechanisms for this are defined in remote.c. gdb/gdbserver/ChangeLog: * linux-low.c (linux_mourn): Static declaration. (linux_arch_setup): Move in front of handle_extended_wait. (linux_arch_setup_thread): New function. (handle_extended_wait): Handle exec events. Call linux_arch_setup_thread. Make event_lwp argument a pointer-to-a-pointer. (check_zombie_leaders): Do not check stopped threads. (linux_low_ptrace_options): Add PTRACE_O_TRACEEXEC. (linux_low_filter_event): Add lwp and thread for exec'ing non-leader thread if leader thread has been deleted. Refactor code into linux_arch_setup_thread and call it. Pass child lwp pointer by reference to handle_extended_wait. (linux_wait_for_event_filtered): Update comment. (linux_wait_1): Prevent clobbering exec event status. (linux_supports_exec_events): New function. (linux_target_ops) <supports_exec_events>: Initialize new member. * lynx-low.c (lynx_target_ops) <supports_exec_events>: Initialize new member. * remote-utils.c (prepare_resume_reply): New stop reason 'exec'. * server.c (report_exec_events): New global variable. (handle_query): Handle qSupported query for exec-events feature. (captured_main): Initialize report_exec_events. * server.h (report_exec_events): Declare new global variable. * target.h (struct target_ops) <supports_exec_events>: New member. (target_supports_exec_events): New macro. * win32-low.c (win32_target_ops) <supports_exec_events>: Initialize new member. gdb/ChangeLog: * infrun.c (follow_exec): Use process-style ptid for exec message. Call add_inferior_with_spaces and target_follow_exec. * nat/linux-ptrace.c (linux_supports_traceexec): New function. * nat/linux-ptrace.h (linux_supports_traceexec): Declare. * remote.c (remote_pspace_data): New static variable. (remote_pspace_data_cleanup): New function. (get_remote_exec_file): New function. (set_remote_exec_file_1): New function. (set_remote_exec_file): New function. (show_remote_exec_file): New function. (remote_exec_file): Delete static variable. (anonymous enum) <PACKET_exec_event_feature> New enumeration constant. (remote_protocol_features): Add entry for exec-events feature. (remote_query_supported): Add client side of qSupported query for exec-events feature. (remote_follow_exec): New function. (remote_parse_stop_reply): Handle 'exec' stop reason. (extended_remote_run, extended_remote_create_inferior): Call get_remote_exec_file and set_remote_exec_file_1. (init_extended_remote_ops) <to_follow_exec>: Initialize new member. (_initialize_remote): Call register_program_space_data_with_cleanup. Call add_packet_config_cmd for remote exec-events feature. Modify call to add_setshow_string_noescape_cmd for exec-file to use new functions set_remote_exec_file and show_remote_exec_file. * target-debug.h, target-delegates.c: Regenerated. * target.c (target_follow_exec): New function. * target.h (struct target_ops) <to_follow_exec>: New member. (target_follow_exec): Declare new function.
2015-09-11 20:06:02 +02:00
options |= PTRACE_O_TRACEEXEC;
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
options |= PTRACE_O_TRACESYSGOOD;
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
return options;
}
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
lwp_info *
linux_process_target::filter_event (int lwpid, int wstat)
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
{
client_state &cs = get_client_state ();
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
struct lwp_info *child;
struct thread_info *thread;
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
int have_stop_pc = 0;
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
child = find_lwp_pid (ptid_t (lwpid));
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
Extended-remote follow-exec This patch implements support for exec events on extended-remote Linux targets. Follow-exec-mode and rerun behave as expected. Catchpoints and test updates are implemented in subsequent patches. This patch was derived from a patch posted last October: https://sourceware.org/ml/gdb-patches/2014-10/msg00877.html. It was originally based on some work done by Luis Machado in 2013. IMPLEMENTATION ---------------- Exec events are enabled via ptrace options. When an exec event is detected by gdbserver, the existing process data, along with all its associated lwp and thread data, is deleted and replaced by data for a new single-threaded process. The new process data is initialized with the appropriate parts of the state of the execing process. This approach takes care of several potential pitfalls, including: * deleting the data for an execing non-leader thread before any wait/sigsuspend occurs * correctly initializing the architecture of the execed process We then report the exec event using a new RSP stop reason, "exec". When GDB receives an "exec" event, it saves the status in the event structure's target_waitstatus field, like what is done for remote fork events. Because the original and execed programs may have different architectures, we skip parsing the section of the stop reply packet that contains register data. The register data will be retrieved later after the inferior's architecture has been set up by infrun.c:follow_exec. At that point the exec event is handled by the existing event handling in GDB. However, a few changes were necessary so that infrun.c:follow_exec could accommodate the remote target. * Where follow-exec-mode "new" is handled, we now call add_inferior_with_spaces instead of add_inferior with separate calls to set up the program and address spaces. The motivation for this is that add_inferior_with_spaces also sets up the initial architecture for the inferior, which is needed later by target_find_description when it calls target_gdbarch. * We call a new target function, target_follow_exec. This function allows us to store the execd_pathname in the inferior, instead of using the static string remote_exec_file from remote.c. The static string didn't work for follow-exec-mode "new", since once you switched to the execed program, the original remote exec-file was lost. The execd_pathname is now stored in the inferior's program space as a REGISTRY field. All of the requisite mechanisms for this are defined in remote.c. gdb/gdbserver/ChangeLog: * linux-low.c (linux_mourn): Static declaration. (linux_arch_setup): Move in front of handle_extended_wait. (linux_arch_setup_thread): New function. (handle_extended_wait): Handle exec events. Call linux_arch_setup_thread. Make event_lwp argument a pointer-to-a-pointer. (check_zombie_leaders): Do not check stopped threads. (linux_low_ptrace_options): Add PTRACE_O_TRACEEXEC. (linux_low_filter_event): Add lwp and thread for exec'ing non-leader thread if leader thread has been deleted. Refactor code into linux_arch_setup_thread and call it. Pass child lwp pointer by reference to handle_extended_wait. (linux_wait_for_event_filtered): Update comment. (linux_wait_1): Prevent clobbering exec event status. (linux_supports_exec_events): New function. (linux_target_ops) <supports_exec_events>: Initialize new member. * lynx-low.c (lynx_target_ops) <supports_exec_events>: Initialize new member. * remote-utils.c (prepare_resume_reply): New stop reason 'exec'. * server.c (report_exec_events): New global variable. (handle_query): Handle qSupported query for exec-events feature. (captured_main): Initialize report_exec_events. * server.h (report_exec_events): Declare new global variable. * target.h (struct target_ops) <supports_exec_events>: New member. (target_supports_exec_events): New macro. * win32-low.c (win32_target_ops) <supports_exec_events>: Initialize new member. gdb/ChangeLog: * infrun.c (follow_exec): Use process-style ptid for exec message. Call add_inferior_with_spaces and target_follow_exec. * nat/linux-ptrace.c (linux_supports_traceexec): New function. * nat/linux-ptrace.h (linux_supports_traceexec): Declare. * remote.c (remote_pspace_data): New static variable. (remote_pspace_data_cleanup): New function. (get_remote_exec_file): New function. (set_remote_exec_file_1): New function. (set_remote_exec_file): New function. (show_remote_exec_file): New function. (remote_exec_file): Delete static variable. (anonymous enum) <PACKET_exec_event_feature> New enumeration constant. (remote_protocol_features): Add entry for exec-events feature. (remote_query_supported): Add client side of qSupported query for exec-events feature. (remote_follow_exec): New function. (remote_parse_stop_reply): Handle 'exec' stop reason. (extended_remote_run, extended_remote_create_inferior): Call get_remote_exec_file and set_remote_exec_file_1. (init_extended_remote_ops) <to_follow_exec>: Initialize new member. (_initialize_remote): Call register_program_space_data_with_cleanup. Call add_packet_config_cmd for remote exec-events feature. Modify call to add_setshow_string_noescape_cmd for exec-file to use new functions set_remote_exec_file and show_remote_exec_file. * target-debug.h, target-delegates.c: Regenerated. * target.c (target_follow_exec): New function. * target.h (struct target_ops) <to_follow_exec>: New member. (target_follow_exec): Declare new function.
2015-09-11 20:06:02 +02:00
/* Check for stop events reported by a process we didn't already
know about - anything not already in our LWP list.
If we're expecting to receive stopped processes after
fork, vfork, and clone events, then we'll just add the
new one to our list and go back to waiting for the event
to be reported - the stopped process might be returned
from waitpid before or after the event is.
But note the case of a non-leader thread exec'ing after the
leader having exited, and gone from our lists (because
check_zombie_leaders deleted it). The non-leader thread
changes its tid to the tgid. */
if (WIFSTOPPED (wstat) && child == NULL && WSTOPSIG (wstat) == SIGTRAP
&& linux_ptrace_get_extended_event (wstat) == PTRACE_EVENT_EXEC)
{
ptid_t child_ptid;
/* A multi-thread exec after we had seen the leader exiting. */
if (debug_threads)
{
debug_printf ("LLW: Re-adding thread group leader LWP %d"
"after exec.\n", lwpid);
}
child_ptid = ptid_t (lwpid, lwpid, 0);
Extended-remote follow-exec This patch implements support for exec events on extended-remote Linux targets. Follow-exec-mode and rerun behave as expected. Catchpoints and test updates are implemented in subsequent patches. This patch was derived from a patch posted last October: https://sourceware.org/ml/gdb-patches/2014-10/msg00877.html. It was originally based on some work done by Luis Machado in 2013. IMPLEMENTATION ---------------- Exec events are enabled via ptrace options. When an exec event is detected by gdbserver, the existing process data, along with all its associated lwp and thread data, is deleted and replaced by data for a new single-threaded process. The new process data is initialized with the appropriate parts of the state of the execing process. This approach takes care of several potential pitfalls, including: * deleting the data for an execing non-leader thread before any wait/sigsuspend occurs * correctly initializing the architecture of the execed process We then report the exec event using a new RSP stop reason, "exec". When GDB receives an "exec" event, it saves the status in the event structure's target_waitstatus field, like what is done for remote fork events. Because the original and execed programs may have different architectures, we skip parsing the section of the stop reply packet that contains register data. The register data will be retrieved later after the inferior's architecture has been set up by infrun.c:follow_exec. At that point the exec event is handled by the existing event handling in GDB. However, a few changes were necessary so that infrun.c:follow_exec could accommodate the remote target. * Where follow-exec-mode "new" is handled, we now call add_inferior_with_spaces instead of add_inferior with separate calls to set up the program and address spaces. The motivation for this is that add_inferior_with_spaces also sets up the initial architecture for the inferior, which is needed later by target_find_description when it calls target_gdbarch. * We call a new target function, target_follow_exec. This function allows us to store the execd_pathname in the inferior, instead of using the static string remote_exec_file from remote.c. The static string didn't work for follow-exec-mode "new", since once you switched to the execed program, the original remote exec-file was lost. The execd_pathname is now stored in the inferior's program space as a REGISTRY field. All of the requisite mechanisms for this are defined in remote.c. gdb/gdbserver/ChangeLog: * linux-low.c (linux_mourn): Static declaration. (linux_arch_setup): Move in front of handle_extended_wait. (linux_arch_setup_thread): New function. (handle_extended_wait): Handle exec events. Call linux_arch_setup_thread. Make event_lwp argument a pointer-to-a-pointer. (check_zombie_leaders): Do not check stopped threads. (linux_low_ptrace_options): Add PTRACE_O_TRACEEXEC. (linux_low_filter_event): Add lwp and thread for exec'ing non-leader thread if leader thread has been deleted. Refactor code into linux_arch_setup_thread and call it. Pass child lwp pointer by reference to handle_extended_wait. (linux_wait_for_event_filtered): Update comment. (linux_wait_1): Prevent clobbering exec event status. (linux_supports_exec_events): New function. (linux_target_ops) <supports_exec_events>: Initialize new member. * lynx-low.c (lynx_target_ops) <supports_exec_events>: Initialize new member. * remote-utils.c (prepare_resume_reply): New stop reason 'exec'. * server.c (report_exec_events): New global variable. (handle_query): Handle qSupported query for exec-events feature. (captured_main): Initialize report_exec_events. * server.h (report_exec_events): Declare new global variable. * target.h (struct target_ops) <supports_exec_events>: New member. (target_supports_exec_events): New macro. * win32-low.c (win32_target_ops) <supports_exec_events>: Initialize new member. gdb/ChangeLog: * infrun.c (follow_exec): Use process-style ptid for exec message. Call add_inferior_with_spaces and target_follow_exec. * nat/linux-ptrace.c (linux_supports_traceexec): New function. * nat/linux-ptrace.h (linux_supports_traceexec): Declare. * remote.c (remote_pspace_data): New static variable. (remote_pspace_data_cleanup): New function. (get_remote_exec_file): New function. (set_remote_exec_file_1): New function. (set_remote_exec_file): New function. (show_remote_exec_file): New function. (remote_exec_file): Delete static variable. (anonymous enum) <PACKET_exec_event_feature> New enumeration constant. (remote_protocol_features): Add entry for exec-events feature. (remote_query_supported): Add client side of qSupported query for exec-events feature. (remote_follow_exec): New function. (remote_parse_stop_reply): Handle 'exec' stop reason. (extended_remote_run, extended_remote_create_inferior): Call get_remote_exec_file and set_remote_exec_file_1. (init_extended_remote_ops) <to_follow_exec>: Initialize new member. (_initialize_remote): Call register_program_space_data_with_cleanup. Call add_packet_config_cmd for remote exec-events feature. Modify call to add_setshow_string_noescape_cmd for exec-file to use new functions set_remote_exec_file and show_remote_exec_file. * target-debug.h, target-delegates.c: Regenerated. * target.c (target_follow_exec): New function. * target.h (struct target_ops) <to_follow_exec>: New member. (target_follow_exec): Declare new function.
2015-09-11 20:06:02 +02:00
child = add_lwp (child_ptid);
child->stopped = 1;
current_thread = child->thread;
}
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
/* If we didn't find a process, one of two things presumably happened:
- A process we started and then detached from has exited. Ignore it.
- A process we are controlling has forked and the new child's stop
was reported to us by the kernel. Save its PID. */
if (child == NULL && WIFSTOPPED (wstat))
{
add_to_pid_list (&stopped_pids, lwpid, wstat);
return NULL;
}
else if (child == NULL)
return NULL;
thread = get_lwp_thread (child);
child->stopped = 1;
child->last_status = wstat;
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
/* Check if the thread has exited. */
if ((WIFEXITED (wstat) || WIFSIGNALED (wstat)))
{
if (debug_threads)
debug_printf ("LLFE: %d exited.\n", lwpid);
Step over exit with reinsert breakpoints This patch fixes a GDBserver crash when one thread is stepping over a syscall instruction which is exit. Step-over isn't finished due to the exit, but GDBserver doesn't clean up the state of step-over, so in the wait next time, GDBserver will wait on step_over_bkpt, which is already exited, and GDBserver crashes because 'requested_child' is NULL. See gdbserver logs below, Need step over [LWP 14858]? yes, found breakpoint at 0x2aaaaad91307^M proceed_all_lwps: found thread 14858 needing a step-over^M Starting step-over on LWP 14858. Stopping all threads^M >>>> entering void stop_all_lwps(int, lwp_info*) .... <<<< exiting void stop_all_lwps(int, lwp_info*)^M Done stopping all threads for step-over.^M pc is 0x2aaaaad91307^M Writing 0f to 0x2aaaaad91307 in process 14858^M Could not find fast tracepoint jump at 0x2aaaaad91307 in list (uninserting).^M pending reinsert at 0x2aaaaad91307^M step from pc 0x2aaaaad91307^M Resuming lwp 14858 (step, signal 0, stop not expected)^M # Start step-over for LWP 14858 >>>> entering ptid_t linux_wait_1(ptid_t, target_waitstatus*, int) .... LLFE: 14858 exited. ... <<<< exiting ptid_t linux_wait_1(ptid_t, target_waitstatus*, int) # LWP 14858 exited ..... >>>> entering ptid_t linux_wait_1(ptid_t, target_waitstatus*, int)^M linux_wait_1: [<all threads>]^M step_over_bkpt set [LWP 14858.14858], doing a blocking wait # but step_over_bkpt is still LWP 14858, which is wrong The fix is to finish step-over if it is ongoing, and unsuspend other threads. Without the fix in linux-low.c, GDBserver will crash in with running gdb.base/step-over-exit.exp. gdb/gdbserver: 2016-06-17 Yao Qi <yao.qi@linaro.org> * linux-low.c (unsuspend_all_lwps): Declare. (linux_low_filter_event): If thread exited, call finish_step_over. If step-over is finished, unsuspend other threads. gdb/testsuite: 2016-06-17 Yao Qi <yao.qi@linaro.org> * gdb.base/step-over-exit.c: New. * gdb.base/step-over-exit.exp: New.
2016-06-17 11:25:12 +02:00
if (finish_step_over (child))
{
/* Unsuspend all other LWPs, and set them back running again. */
unsuspend_all_lwps (child);
}
Remote thread create/exit events When testing with "maint set target-non-stop on", a few threading-related tests expose an issue that requires new RSP packets. Say there are 3 threads running, 1-3. If GDB tries to stop thread 1, 2 and 3, and then waits for their stops, but meanwhile say, thread 2 exits, GDB hangs forever waiting for a stop for thread 2 that won't ever happen. This patch fixes the issue by adding support for thread exit events to the protocol. However, we don't want these always enabled, as they're useless most of the time, and would slow down remote debugging. So I made it so that GDB can enable/disable them, and then made gdb do that around the cases that need it, which currently is only infrun.c:stop_all_threads. In turn, if we have thread exit events, then the extra "thread x exited" traffic slows down attach-many-short-lived-threads.exp enough that gdb has trouble keeping up with new threads that are spawned while gdb tries to stop existing ones. To fix that I added support for the counterpart thread created events too. Enabling those when we try to stop threads ensures that new threads never get a chance to themselves start new threads, killing the race. gdb/doc/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): List "set/show remote thread-events" command in configuration table. (Stop Reply Packets): Document "T05 create" stop reason and 'w' stop reply. (General Query Packets): Document QThreadEvents packet. Document QThreadEvents qSupported feature. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. If GDB wants to hear about thread create events, leave the new child's status pending. (linux_low_filter_event): If GDB wants to hear about thread exit events, leave the LWP marked dead and don't delete it. (linux_wait_for_event_filtered): Don't check for thread exit. (filter_exit_event): New function. (linux_wait_1): Use it, when returning an exit event. (linux_resume_one_lwp_throw): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. * remote-utils.c (prepare_resume_reply): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.c (report_thread_events): New global. (handle_general_set): Handle QThreadEvents. (handle_query) <qSupported>: Handle and report QThreadEvents+; (handle_target_event): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.h (report_thread_events): Declare. gdb/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * NEWS (New commands): Mention "set/show remote thread-events" commands. (New remote packets): Mention thread created/exited stop reasons and QThreadEvents packet. * infrun.c (disable_thread_events): New function. (stop_all_threads): Disable/enable thread create/exit events. Handle TARGET_WAITKIND_THREAD_EXITED. (handle_inferior_event_1): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * remote.c (remove_child_of_pending_fork): Also remove threads of threads that have TARGET_WAITKIND_THREAD_EXITED events. (remote_parse_stop_reply): Handle "create" magic register. Handle 'w' stop reply. (initialize_remote): Install remote_thread_events as to_thread_events target hook. (remote_thread_events): New function. * target-delegates.c: Regenerate. * target.c (target_thread_events): New function. * target.h (struct target_ops) <to_thread_events>: New field. (target_thread_events): Declare. * target/waitstatus.c (target_waitstatus_to_string): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * target/waitstatus.h (enum target_waitkind) <TARGET_WAITKIND_THREAD_CREATED, TARGET_WAITKIND_THREAD_EXITED): New values.
2015-11-30 17:05:21 +01:00
/* If there is at least one more LWP, then the exit signal was
not the end of the debugged application and should be
ignored, unless GDB wants to hear about thread exits. */
if (cs.report_thread_events
Remote thread create/exit events When testing with "maint set target-non-stop on", a few threading-related tests expose an issue that requires new RSP packets. Say there are 3 threads running, 1-3. If GDB tries to stop thread 1, 2 and 3, and then waits for their stops, but meanwhile say, thread 2 exits, GDB hangs forever waiting for a stop for thread 2 that won't ever happen. This patch fixes the issue by adding support for thread exit events to the protocol. However, we don't want these always enabled, as they're useless most of the time, and would slow down remote debugging. So I made it so that GDB can enable/disable them, and then made gdb do that around the cases that need it, which currently is only infrun.c:stop_all_threads. In turn, if we have thread exit events, then the extra "thread x exited" traffic slows down attach-many-short-lived-threads.exp enough that gdb has trouble keeping up with new threads that are spawned while gdb tries to stop existing ones. To fix that I added support for the counterpart thread created events too. Enabling those when we try to stop threads ensures that new threads never get a chance to themselves start new threads, killing the race. gdb/doc/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): List "set/show remote thread-events" command in configuration table. (Stop Reply Packets): Document "T05 create" stop reason and 'w' stop reply. (General Query Packets): Document QThreadEvents packet. Document QThreadEvents qSupported feature. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. If GDB wants to hear about thread create events, leave the new child's status pending. (linux_low_filter_event): If GDB wants to hear about thread exit events, leave the LWP marked dead and don't delete it. (linux_wait_for_event_filtered): Don't check for thread exit. (filter_exit_event): New function. (linux_wait_1): Use it, when returning an exit event. (linux_resume_one_lwp_throw): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. * remote-utils.c (prepare_resume_reply): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.c (report_thread_events): New global. (handle_general_set): Handle QThreadEvents. (handle_query) <qSupported>: Handle and report QThreadEvents+; (handle_target_event): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.h (report_thread_events): Declare. gdb/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * NEWS (New commands): Mention "set/show remote thread-events" commands. (New remote packets): Mention thread created/exited stop reasons and QThreadEvents packet. * infrun.c (disable_thread_events): New function. (stop_all_threads): Disable/enable thread create/exit events. Handle TARGET_WAITKIND_THREAD_EXITED. (handle_inferior_event_1): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * remote.c (remove_child_of_pending_fork): Also remove threads of threads that have TARGET_WAITKIND_THREAD_EXITED events. (remote_parse_stop_reply): Handle "create" magic register. Handle 'w' stop reply. (initialize_remote): Install remote_thread_events as to_thread_events target hook. (remote_thread_events): New function. * target-delegates.c: Regenerate. * target.c (target_thread_events): New function. * target.h (struct target_ops) <to_thread_events>: New field. (target_thread_events): Declare. * target/waitstatus.c (target_waitstatus_to_string): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * target/waitstatus.h (enum target_waitkind) <TARGET_WAITKIND_THREAD_CREATED, TARGET_WAITKIND_THREAD_EXITED): New values.
2015-11-30 17:05:21 +01:00
|| last_thread_of_process_p (pid_of (thread)))
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
{
Remote thread create/exit events When testing with "maint set target-non-stop on", a few threading-related tests expose an issue that requires new RSP packets. Say there are 3 threads running, 1-3. If GDB tries to stop thread 1, 2 and 3, and then waits for their stops, but meanwhile say, thread 2 exits, GDB hangs forever waiting for a stop for thread 2 that won't ever happen. This patch fixes the issue by adding support for thread exit events to the protocol. However, we don't want these always enabled, as they're useless most of the time, and would slow down remote debugging. So I made it so that GDB can enable/disable them, and then made gdb do that around the cases that need it, which currently is only infrun.c:stop_all_threads. In turn, if we have thread exit events, then the extra "thread x exited" traffic slows down attach-many-short-lived-threads.exp enough that gdb has trouble keeping up with new threads that are spawned while gdb tries to stop existing ones. To fix that I added support for the counterpart thread created events too. Enabling those when we try to stop threads ensures that new threads never get a chance to themselves start new threads, killing the race. gdb/doc/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): List "set/show remote thread-events" command in configuration table. (Stop Reply Packets): Document "T05 create" stop reason and 'w' stop reply. (General Query Packets): Document QThreadEvents packet. Document QThreadEvents qSupported feature. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. If GDB wants to hear about thread create events, leave the new child's status pending. (linux_low_filter_event): If GDB wants to hear about thread exit events, leave the LWP marked dead and don't delete it. (linux_wait_for_event_filtered): Don't check for thread exit. (filter_exit_event): New function. (linux_wait_1): Use it, when returning an exit event. (linux_resume_one_lwp_throw): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. * remote-utils.c (prepare_resume_reply): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.c (report_thread_events): New global. (handle_general_set): Handle QThreadEvents. (handle_query) <qSupported>: Handle and report QThreadEvents+; (handle_target_event): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.h (report_thread_events): Declare. gdb/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * NEWS (New commands): Mention "set/show remote thread-events" commands. (New remote packets): Mention thread created/exited stop reasons and QThreadEvents packet. * infrun.c (disable_thread_events): New function. (stop_all_threads): Disable/enable thread create/exit events. Handle TARGET_WAITKIND_THREAD_EXITED. (handle_inferior_event_1): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * remote.c (remove_child_of_pending_fork): Also remove threads of threads that have TARGET_WAITKIND_THREAD_EXITED events. (remote_parse_stop_reply): Handle "create" magic register. Handle 'w' stop reply. (initialize_remote): Install remote_thread_events as to_thread_events target hook. (remote_thread_events): New function. * target-delegates.c: Regenerate. * target.c (target_thread_events): New function. * target.h (struct target_ops) <to_thread_events>: New field. (target_thread_events): Declare. * target/waitstatus.c (target_waitstatus_to_string): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * target/waitstatus.h (enum target_waitkind) <TARGET_WAITKIND_THREAD_CREATED, TARGET_WAITKIND_THREAD_EXITED): New values.
2015-11-30 17:05:21 +01:00
/* Since events are serialized to GDB core, and we can't
report this one right now. Leave the status pending for
the next time we're able to report it. */
mark_lwp_dead (child, wstat);
return child;
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
}
else
{
Remote thread create/exit events When testing with "maint set target-non-stop on", a few threading-related tests expose an issue that requires new RSP packets. Say there are 3 threads running, 1-3. If GDB tries to stop thread 1, 2 and 3, and then waits for their stops, but meanwhile say, thread 2 exits, GDB hangs forever waiting for a stop for thread 2 that won't ever happen. This patch fixes the issue by adding support for thread exit events to the protocol. However, we don't want these always enabled, as they're useless most of the time, and would slow down remote debugging. So I made it so that GDB can enable/disable them, and then made gdb do that around the cases that need it, which currently is only infrun.c:stop_all_threads. In turn, if we have thread exit events, then the extra "thread x exited" traffic slows down attach-many-short-lived-threads.exp enough that gdb has trouble keeping up with new threads that are spawned while gdb tries to stop existing ones. To fix that I added support for the counterpart thread created events too. Enabling those when we try to stop threads ensures that new threads never get a chance to themselves start new threads, killing the race. gdb/doc/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): List "set/show remote thread-events" command in configuration table. (Stop Reply Packets): Document "T05 create" stop reason and 'w' stop reply. (General Query Packets): Document QThreadEvents packet. Document QThreadEvents qSupported feature. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. If GDB wants to hear about thread create events, leave the new child's status pending. (linux_low_filter_event): If GDB wants to hear about thread exit events, leave the LWP marked dead and don't delete it. (linux_wait_for_event_filtered): Don't check for thread exit. (filter_exit_event): New function. (linux_wait_1): Use it, when returning an exit event. (linux_resume_one_lwp_throw): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. * remote-utils.c (prepare_resume_reply): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.c (report_thread_events): New global. (handle_general_set): Handle QThreadEvents. (handle_query) <qSupported>: Handle and report QThreadEvents+; (handle_target_event): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.h (report_thread_events): Declare. gdb/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * NEWS (New commands): Mention "set/show remote thread-events" commands. (New remote packets): Mention thread created/exited stop reasons and QThreadEvents packet. * infrun.c (disable_thread_events): New function. (stop_all_threads): Disable/enable thread create/exit events. Handle TARGET_WAITKIND_THREAD_EXITED. (handle_inferior_event_1): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * remote.c (remove_child_of_pending_fork): Also remove threads of threads that have TARGET_WAITKIND_THREAD_EXITED events. (remote_parse_stop_reply): Handle "create" magic register. Handle 'w' stop reply. (initialize_remote): Install remote_thread_events as to_thread_events target hook. (remote_thread_events): New function. * target-delegates.c: Regenerate. * target.c (target_thread_events): New function. * target.h (struct target_ops) <to_thread_events>: New field. (target_thread_events): Declare. * target/waitstatus.c (target_waitstatus_to_string): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * target/waitstatus.h (enum target_waitkind) <TARGET_WAITKIND_THREAD_CREATED, TARGET_WAITKIND_THREAD_EXITED): New values.
2015-11-30 17:05:21 +01:00
delete_lwp (child);
return NULL;
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
}
}
gdb_assert (WIFSTOPPED (wstat));
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
if (WIFSTOPPED (wstat))
{
struct process_info *proc;
Initialise target descrption after skipping extra traps for --wrapper Nowadays, when --wrapper is used, GDBserver skips extra traps/stops in the wrapper program, and stops at the first instruction of the program to be debugged. However, GDBserver created target description in the first stop of inferior, and the executable of the inferior is the wrapper program rather than the program to be debugged. In this way, the target description can be wrong if the architectures of wrapper program and program to be debugged are different. This is shown by some fails in gdb.server/wrapper.exp on buildbot. We are testing i686-linux GDB (Fedora-i686) on an x86_64-linux box (fedora-x86-64-4) in buildbot, such configuration causes fails in gdb.server/wrapper.exp like this: spawn /home/gdb-buildbot-2/fedora-x86-64-4/fedora-i686/build/gdb/testsuite/../../gdb/gdbserver/gdbserver --once --wrapper env TEST=1 -- :2346 /home/gdb-buildbot-2/fedora-x86-64-4/fedora-i686/build/gdb/testsuite/outputs/gdb.server/wrapper/wrapper Process /home/gdb-buildbot-2/fedora-x86-64-4/fedora-i686/build/gdb/testsuite/outputs/gdb.server/wrapper/wrapper created; pid = 8795 Can't debug 64-bit process with 32-bit GDBserver Exiting target remote localhost:2346 localhost:2346: Connection timed out. (gdb) FAIL: gdb.server/wrapper.exp: setting breakpoint at marker See https://sourceware.org/ml/gdb-testers/2015-q3/msg01541.html In this case, program to be debugged ("wrapper") is 32-bit but wrapper program ("/usr/bin/env") is 64-bit, so GDBserver gets the 64-bit target description instead of 32-bit. The root cause of this problem is that GDBserver creates target description too early, and the rationale of fix could be creating target description once the GDBserver skips extra traps and inferior stops at the first instruction of the program we want to debug. IOW, when GDBserver skips extra traps, the inferior's tdesc is NULL, and mywait and its callees shouldn't use inferior's tdesc, so in this patch, we skip code that requires register access, see changes in linux_resume_one_lwp_throw and need_step_over_p. In linux_low_filter_event, if target description isn't initialised and GDBserver attached the process, we create target description immediately, because GDBserver don't have to skip extra traps for attach, IOW, it makes no sense to use --attach and --wrapper together. Otherwise, the process is launched by GDBserver, we keep the status pending, and return. After GDBserver skipped extra traps in start_inferior, we call a target_ops hook arch_setup to initialise target description there. gdb/gdbserver: 2015-07-24 Yao Qi <yao.qi@linaro.org> * linux-low.c (linux_arch_setup): New function. (linux_low_filter_event): If proc->tdesc is NULL and proc->attached is true, call the_low_target.arch_setup. Otherwise, keep status pending, and return. (linux_resume_one_lwp_throw): Don't call get_pc if thread->while_stepping isn't NULL. Don't call get_thread_regcache if proc->tdesc is NULL. (need_step_over_p): Return 0 if proc->tdesc is NULL. (linux_target_ops): Install arch_setup. * server.c (start_inferior): Call the_target->arch_setup. * target.h (struct target_ops) <arch_setup>: New field. (target_arch_setup): New marco. * lynx-low.c (lynx_target_ops): Update. * nto-low.c (nto_target_ops): Update. * spu-low.c (spu_target_ops): Update. * win32-low.c (win32_target_ops): Update.
2015-07-24 15:40:34 +02:00
/* Architecture-specific setup after inferior is running. */
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
proc = find_process_pid (pid_of (thread));
Initialise target descrption after skipping extra traps for --wrapper Nowadays, when --wrapper is used, GDBserver skips extra traps/stops in the wrapper program, and stops at the first instruction of the program to be debugged. However, GDBserver created target description in the first stop of inferior, and the executable of the inferior is the wrapper program rather than the program to be debugged. In this way, the target description can be wrong if the architectures of wrapper program and program to be debugged are different. This is shown by some fails in gdb.server/wrapper.exp on buildbot. We are testing i686-linux GDB (Fedora-i686) on an x86_64-linux box (fedora-x86-64-4) in buildbot, such configuration causes fails in gdb.server/wrapper.exp like this: spawn /home/gdb-buildbot-2/fedora-x86-64-4/fedora-i686/build/gdb/testsuite/../../gdb/gdbserver/gdbserver --once --wrapper env TEST=1 -- :2346 /home/gdb-buildbot-2/fedora-x86-64-4/fedora-i686/build/gdb/testsuite/outputs/gdb.server/wrapper/wrapper Process /home/gdb-buildbot-2/fedora-x86-64-4/fedora-i686/build/gdb/testsuite/outputs/gdb.server/wrapper/wrapper created; pid = 8795 Can't debug 64-bit process with 32-bit GDBserver Exiting target remote localhost:2346 localhost:2346: Connection timed out. (gdb) FAIL: gdb.server/wrapper.exp: setting breakpoint at marker See https://sourceware.org/ml/gdb-testers/2015-q3/msg01541.html In this case, program to be debugged ("wrapper") is 32-bit but wrapper program ("/usr/bin/env") is 64-bit, so GDBserver gets the 64-bit target description instead of 32-bit. The root cause of this problem is that GDBserver creates target description too early, and the rationale of fix could be creating target description once the GDBserver skips extra traps and inferior stops at the first instruction of the program we want to debug. IOW, when GDBserver skips extra traps, the inferior's tdesc is NULL, and mywait and its callees shouldn't use inferior's tdesc, so in this patch, we skip code that requires register access, see changes in linux_resume_one_lwp_throw and need_step_over_p. In linux_low_filter_event, if target description isn't initialised and GDBserver attached the process, we create target description immediately, because GDBserver don't have to skip extra traps for attach, IOW, it makes no sense to use --attach and --wrapper together. Otherwise, the process is launched by GDBserver, we keep the status pending, and return. After GDBserver skipped extra traps in start_inferior, we call a target_ops hook arch_setup to initialise target description there. gdb/gdbserver: 2015-07-24 Yao Qi <yao.qi@linaro.org> * linux-low.c (linux_arch_setup): New function. (linux_low_filter_event): If proc->tdesc is NULL and proc->attached is true, call the_low_target.arch_setup. Otherwise, keep status pending, and return. (linux_resume_one_lwp_throw): Don't call get_pc if thread->while_stepping isn't NULL. Don't call get_thread_regcache if proc->tdesc is NULL. (need_step_over_p): Return 0 if proc->tdesc is NULL. (linux_target_ops): Install arch_setup. * server.c (start_inferior): Call the_target->arch_setup. * target.h (struct target_ops) <arch_setup>: New field. (target_arch_setup): New marco. * lynx-low.c (lynx_target_ops): Update. * nto-low.c (nto_target_ops): Update. * spu-low.c (spu_target_ops): Update. * win32-low.c (win32_target_ops): Update.
2015-07-24 15:40:34 +02:00
if (proc->tdesc == NULL)
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
{
Initialise target descrption after skipping extra traps for --wrapper Nowadays, when --wrapper is used, GDBserver skips extra traps/stops in the wrapper program, and stops at the first instruction of the program to be debugged. However, GDBserver created target description in the first stop of inferior, and the executable of the inferior is the wrapper program rather than the program to be debugged. In this way, the target description can be wrong if the architectures of wrapper program and program to be debugged are different. This is shown by some fails in gdb.server/wrapper.exp on buildbot. We are testing i686-linux GDB (Fedora-i686) on an x86_64-linux box (fedora-x86-64-4) in buildbot, such configuration causes fails in gdb.server/wrapper.exp like this: spawn /home/gdb-buildbot-2/fedora-x86-64-4/fedora-i686/build/gdb/testsuite/../../gdb/gdbserver/gdbserver --once --wrapper env TEST=1 -- :2346 /home/gdb-buildbot-2/fedora-x86-64-4/fedora-i686/build/gdb/testsuite/outputs/gdb.server/wrapper/wrapper Process /home/gdb-buildbot-2/fedora-x86-64-4/fedora-i686/build/gdb/testsuite/outputs/gdb.server/wrapper/wrapper created; pid = 8795 Can't debug 64-bit process with 32-bit GDBserver Exiting target remote localhost:2346 localhost:2346: Connection timed out. (gdb) FAIL: gdb.server/wrapper.exp: setting breakpoint at marker See https://sourceware.org/ml/gdb-testers/2015-q3/msg01541.html In this case, program to be debugged ("wrapper") is 32-bit but wrapper program ("/usr/bin/env") is 64-bit, so GDBserver gets the 64-bit target description instead of 32-bit. The root cause of this problem is that GDBserver creates target description too early, and the rationale of fix could be creating target description once the GDBserver skips extra traps and inferior stops at the first instruction of the program we want to debug. IOW, when GDBserver skips extra traps, the inferior's tdesc is NULL, and mywait and its callees shouldn't use inferior's tdesc, so in this patch, we skip code that requires register access, see changes in linux_resume_one_lwp_throw and need_step_over_p. In linux_low_filter_event, if target description isn't initialised and GDBserver attached the process, we create target description immediately, because GDBserver don't have to skip extra traps for attach, IOW, it makes no sense to use --attach and --wrapper together. Otherwise, the process is launched by GDBserver, we keep the status pending, and return. After GDBserver skipped extra traps in start_inferior, we call a target_ops hook arch_setup to initialise target description there. gdb/gdbserver: 2015-07-24 Yao Qi <yao.qi@linaro.org> * linux-low.c (linux_arch_setup): New function. (linux_low_filter_event): If proc->tdesc is NULL and proc->attached is true, call the_low_target.arch_setup. Otherwise, keep status pending, and return. (linux_resume_one_lwp_throw): Don't call get_pc if thread->while_stepping isn't NULL. Don't call get_thread_regcache if proc->tdesc is NULL. (need_step_over_p): Return 0 if proc->tdesc is NULL. (linux_target_ops): Install arch_setup. * server.c (start_inferior): Call the_target->arch_setup. * target.h (struct target_ops) <arch_setup>: New field. (target_arch_setup): New marco. * lynx-low.c (lynx_target_ops): Update. * nto-low.c (nto_target_ops): Update. * spu-low.c (spu_target_ops): Update. * win32-low.c (win32_target_ops): Update.
2015-07-24 15:40:34 +02:00
if (proc->attached)
{
/* This needs to happen after we have attached to the
inferior and it is stopped for the first time, but
before we access any inferior registers. */
gdbserver/linux-low: turn 'arch_setup' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'arch_setup' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops) <arch_setup>: Delete. (class linux_process_target) <arch_setup_thread> <low_arch_setup>: New declarations. * linux-low.cc (linux_arch_setup): Delete. (linux_arch_setup_thread): Turn into... (linux_process_target::arch_setup_thread): ... this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::post_create_inferior) (linux_process_target::filter_event) * linux-x86-low.cc (class x86_target) <low_arch_setup>: New declaration. (x86_linux_update_xmltarget): Turn into... (x86_target::update_xmltarget): ...this. (x86_linux_process_qsupported): Update the call to x86_linux_update_xmltarget. (x86_arch_setup): Turn into ... (x86_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <low_arch_setup>: New declaration. (aarch64_arch_setup): Turn into ... (aarch64_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (class arm_target) <low_arch_setup>: New declaration. (arm_arch_setup): Turn into ... (arm_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-bfin-low.cc (class bfin_target) <low_arch_setup>: New declaration. (bfin_arch_setup): Turn into ... (bfin_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-cris-low.cc (class cris_target) <low_arch_setup>: New declaration. (cris_arch_setup): Turn into ... (cris_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-crisv32-low.cc (class crisv32_target) <low_arch_setup>: New declaration. (crisv32_arch_setup): Turn into ... (crisv32_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-ia64-low.cc (class ia64_target) <low_arch_setup>: New declaration. (ia64_arch_setup): Turn into ... (ia64_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-m32r-low.cc (class m32r_target) <low_arch_setup>: New declaration. (m32r_arch_setup): Turn into ... (m32r_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-m68k-low.cc (class m68k_target) <low_arch_setup>: New declaration. (m68k_arch_setup): Turn into ... (m68k_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-mips-low.cc (class mips_target) <low_arch_setup>: New declaration. (mips_arch_setup): Turn into ... (mips_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-nios2-low.cc (class nios2_target) <low_arch_setup>: New declaration. (nios2_arch_setup): Turn into ... (nios2_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (class ppc_target) <low_arch_setup>: New declaration. (ppc_arch_setup): Turn into ... (ppc_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-riscv-low.cc (class riscv_target) <low_arch_setup>: New declaration. (riscv_arch_setup): Turn into ... (riscv_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-s390-low.cc (class s390_target) <low_arch_setup>: New declaration. (s390_arch_setup): Turn into ... (s390_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-sh-low.cc (class sh_target) <low_arch_setup>: New declaration. (sh_arch_setup): Turn into ... (sh_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-sparc-low.cc (class sparc_target) <low_arch_setup>: New declaration. (sparc_arch_setup): Turn into ... (sparc_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-tic6x-low.cc (class tic6x_target) <low_arch_setup>: New declaration. (tic6x_arch_setup): Turn into ... (tic6x_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-tile-low.cc (class tile_target) <low_arch_setup>: New declaration. (tile_arch_setup): Turn into ... (tile_target::low_arch_setup): ...this. (the_low_target): Remove the op field. * linux-xtensa-low.cc (class xtensa_target) <low_arch_setup>: New declaration. (xtensa_arch_setup): Turn into ... (xtensa_target::low_arch_setup): ...this. (the_low_target): Remove the op field.
2020-04-02 15:11:23 +02:00
arch_setup_thread (thread);
Initialise target descrption after skipping extra traps for --wrapper Nowadays, when --wrapper is used, GDBserver skips extra traps/stops in the wrapper program, and stops at the first instruction of the program to be debugged. However, GDBserver created target description in the first stop of inferior, and the executable of the inferior is the wrapper program rather than the program to be debugged. In this way, the target description can be wrong if the architectures of wrapper program and program to be debugged are different. This is shown by some fails in gdb.server/wrapper.exp on buildbot. We are testing i686-linux GDB (Fedora-i686) on an x86_64-linux box (fedora-x86-64-4) in buildbot, such configuration causes fails in gdb.server/wrapper.exp like this: spawn /home/gdb-buildbot-2/fedora-x86-64-4/fedora-i686/build/gdb/testsuite/../../gdb/gdbserver/gdbserver --once --wrapper env TEST=1 -- :2346 /home/gdb-buildbot-2/fedora-x86-64-4/fedora-i686/build/gdb/testsuite/outputs/gdb.server/wrapper/wrapper Process /home/gdb-buildbot-2/fedora-x86-64-4/fedora-i686/build/gdb/testsuite/outputs/gdb.server/wrapper/wrapper created; pid = 8795 Can't debug 64-bit process with 32-bit GDBserver Exiting target remote localhost:2346 localhost:2346: Connection timed out. (gdb) FAIL: gdb.server/wrapper.exp: setting breakpoint at marker See https://sourceware.org/ml/gdb-testers/2015-q3/msg01541.html In this case, program to be debugged ("wrapper") is 32-bit but wrapper program ("/usr/bin/env") is 64-bit, so GDBserver gets the 64-bit target description instead of 32-bit. The root cause of this problem is that GDBserver creates target description too early, and the rationale of fix could be creating target description once the GDBserver skips extra traps and inferior stops at the first instruction of the program we want to debug. IOW, when GDBserver skips extra traps, the inferior's tdesc is NULL, and mywait and its callees shouldn't use inferior's tdesc, so in this patch, we skip code that requires register access, see changes in linux_resume_one_lwp_throw and need_step_over_p. In linux_low_filter_event, if target description isn't initialised and GDBserver attached the process, we create target description immediately, because GDBserver don't have to skip extra traps for attach, IOW, it makes no sense to use --attach and --wrapper together. Otherwise, the process is launched by GDBserver, we keep the status pending, and return. After GDBserver skipped extra traps in start_inferior, we call a target_ops hook arch_setup to initialise target description there. gdb/gdbserver: 2015-07-24 Yao Qi <yao.qi@linaro.org> * linux-low.c (linux_arch_setup): New function. (linux_low_filter_event): If proc->tdesc is NULL and proc->attached is true, call the_low_target.arch_setup. Otherwise, keep status pending, and return. (linux_resume_one_lwp_throw): Don't call get_pc if thread->while_stepping isn't NULL. Don't call get_thread_regcache if proc->tdesc is NULL. (need_step_over_p): Return 0 if proc->tdesc is NULL. (linux_target_ops): Install arch_setup. * server.c (start_inferior): Call the_target->arch_setup. * target.h (struct target_ops) <arch_setup>: New field. (target_arch_setup): New marco. * lynx-low.c (lynx_target_ops): Update. * nto-low.c (nto_target_ops): Update. * spu-low.c (spu_target_ops): Update. * win32-low.c (win32_target_ops): Update.
2015-07-24 15:40:34 +02:00
}
else
{
/* The process is started, but GDBserver will do
architecture-specific setup after the program stops at
the first instruction. */
child->status_pending_p = 1;
child->status_pending = wstat;
return child;
}
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
}
}
if (WIFSTOPPED (wstat) && child->must_set_ptrace_flags)
{
[Linux] Ask kernel to kill inferior when GDB terminates This patch enhances GDB on GNU/Linux systems in the situation where we are debugging an inferior that was created from GDB (as opposed to attached to), by asking the kernel to kill the inferior if GDB terminates without doing it itself. This would typically happen when GDB encounters a problem and crashes, or when it gets killed by an external process. This can be observed by starting a program under GDB, and then killing GDB with signal 9. After GDB is killed, the inferior still remains. This patch also fixes GDBserver similarly. This fix is conditional on the kernel supporting the PTRACE_O_EXITKILL feature. On older kernels, the behavior remains unchanged. gdb/ChangeLog: * nat/linux-ptrace.h (PTRACE_O_EXITKILL): Define if not already defined. (linux_enable_event_reporting): Add parameter "attached". * nat/linux-ptrace.c (linux_test_for_exitkill): New forward declaration. New function. (linux_check_ptrace_features): Add linux_test_for_exitkill call. (linux_enable_event_reporting): Add new parameter "attached". Do not call ptrace with the PTRACE_O_EXITKILL if ATTACHED is nonzero. * linux-nat.c (linux_init_ptrace): Add parameter "attached". Use it. Update function description. (linux_child_post_attach, linux_child_post_startup_inferior): Update call to linux_enable_event_reporting. gdb/gdbserver/ChangeLog: * linux-low.c (linux_low_filter_event): Update call to linux_enable_event_reporting following the addition of a new parameter to that function. Tested on x86_64-linux, native and native-gdbserver. I also verified by hand that the inferior gets killed when killing GDB in the "run" case, while the inferior remains in the "attach" case. Same for GDBserver.
2014-11-11 07:07:21 +01:00
struct process_info *proc = find_process_pid (pid_of (thread));
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
int options = linux_low_ptrace_options (proc->attached);
[Linux] Ask kernel to kill inferior when GDB terminates This patch enhances GDB on GNU/Linux systems in the situation where we are debugging an inferior that was created from GDB (as opposed to attached to), by asking the kernel to kill the inferior if GDB terminates without doing it itself. This would typically happen when GDB encounters a problem and crashes, or when it gets killed by an external process. This can be observed by starting a program under GDB, and then killing GDB with signal 9. After GDB is killed, the inferior still remains. This patch also fixes GDBserver similarly. This fix is conditional on the kernel supporting the PTRACE_O_EXITKILL feature. On older kernels, the behavior remains unchanged. gdb/ChangeLog: * nat/linux-ptrace.h (PTRACE_O_EXITKILL): Define if not already defined. (linux_enable_event_reporting): Add parameter "attached". * nat/linux-ptrace.c (linux_test_for_exitkill): New forward declaration. New function. (linux_check_ptrace_features): Add linux_test_for_exitkill call. (linux_enable_event_reporting): Add new parameter "attached". Do not call ptrace with the PTRACE_O_EXITKILL if ATTACHED is nonzero. * linux-nat.c (linux_init_ptrace): Add parameter "attached". Use it. Update function description. (linux_child_post_attach, linux_child_post_startup_inferior): Update call to linux_enable_event_reporting. gdb/gdbserver/ChangeLog: * linux-low.c (linux_low_filter_event): Update call to linux_enable_event_reporting following the addition of a new parameter to that function. Tested on x86_64-linux, native and native-gdbserver. I also verified by hand that the inferior gets killed when killing GDB in the "run" case, while the inferior remains in the "attach" case. Same for GDBserver.
2014-11-11 07:07:21 +01:00
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
linux_enable_event_reporting (lwpid, options);
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
child->must_set_ptrace_flags = 0;
}
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
/* Always update syscall_state, even if it will be filtered later. */
if (WIFSTOPPED (wstat) && WSTOPSIG (wstat) == SYSCALL_SIGTRAP)
{
child->syscall_state
= (child->syscall_state == TARGET_WAITKIND_SYSCALL_ENTRY
? TARGET_WAITKIND_SYSCALL_RETURN
: TARGET_WAITKIND_SYSCALL_ENTRY);
}
else
{
/* Almost all other ptrace-stops are known to be outside of system
calls, with further exceptions in handle_extended_wait. */
child->syscall_state = TARGET_WAITKIND_IGNORE;
}
Handle MIPS Linux SIGTRAP siginfo.si_code values This unbreaks pending/delayed breakpoints handling, as well as hardware watchpoints, on MIPS. Ref: https://sourceware.org/ml/gdb-patches/2016-02/msg00681.html The MIPS kernel reports SI_KERNEL for all kernel generated traps, instead of TRAP_BRKPT / TRAP_HWBKPT, but GDB isn't aware of this. Basically, this commit: - Folds watchpoints logic into check_stopped_by_breakpoint, and renames it to save_stop_reason. - Adds GDB_ARCH_IS_TRAP_HWBKPT. - Makes MIPS set both GDB_ARCH_IS_TRAP_BRPT and GDB_ARCH_IS_TRAP_HWBKPT to SI_KERNEL. In save_stop_reason, we handle the case of the same si_code returning true for both TRAP_BRPT and TRAP_HWBKPT by looking at what the debug registers say. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-nat.c (save_sigtrap) Delete. (stop_wait_callback): Call save_stop_reason instead of save_sigtrap. (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Bits of save_sigtrap folded here. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_nat_filter_event): Call save_stop_reason instead of save_sigtrap. * nat/linux-ptrace.h: Check for both SI_KERNEL and TRAP_BRKPT si_code for MIPS. * nat/linux-ptrace.h: Fix "TRAP_HWBPT" typo in x86 table. Add comments on MIPS behavior. (GDB_ARCH_IS_TRAP_HWBKPT): Define for all archs. gdb/gdbserver/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-low.c (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_low_filter_event): Call save_stop_reason instead of check_stopped_by_breakpoint and check_stopped_by_watchpoint. Update comments. (linux_wait_1): Update comments.
2016-02-24 23:52:06 +01:00
/* Be careful to not overwrite stop_pc until save_stop_reason is
called. */
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
if (WIFSTOPPED (wstat) && WSTOPSIG (wstat) == SIGTRAP
&& linux_is_extended_waitstatus (wstat))
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
{
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
child->stop_pc = get_pc (child);
Extended-remote follow-exec This patch implements support for exec events on extended-remote Linux targets. Follow-exec-mode and rerun behave as expected. Catchpoints and test updates are implemented in subsequent patches. This patch was derived from a patch posted last October: https://sourceware.org/ml/gdb-patches/2014-10/msg00877.html. It was originally based on some work done by Luis Machado in 2013. IMPLEMENTATION ---------------- Exec events are enabled via ptrace options. When an exec event is detected by gdbserver, the existing process data, along with all its associated lwp and thread data, is deleted and replaced by data for a new single-threaded process. The new process data is initialized with the appropriate parts of the state of the execing process. This approach takes care of several potential pitfalls, including: * deleting the data for an execing non-leader thread before any wait/sigsuspend occurs * correctly initializing the architecture of the execed process We then report the exec event using a new RSP stop reason, "exec". When GDB receives an "exec" event, it saves the status in the event structure's target_waitstatus field, like what is done for remote fork events. Because the original and execed programs may have different architectures, we skip parsing the section of the stop reply packet that contains register data. The register data will be retrieved later after the inferior's architecture has been set up by infrun.c:follow_exec. At that point the exec event is handled by the existing event handling in GDB. However, a few changes were necessary so that infrun.c:follow_exec could accommodate the remote target. * Where follow-exec-mode "new" is handled, we now call add_inferior_with_spaces instead of add_inferior with separate calls to set up the program and address spaces. The motivation for this is that add_inferior_with_spaces also sets up the initial architecture for the inferior, which is needed later by target_find_description when it calls target_gdbarch. * We call a new target function, target_follow_exec. This function allows us to store the execd_pathname in the inferior, instead of using the static string remote_exec_file from remote.c. The static string didn't work for follow-exec-mode "new", since once you switched to the execed program, the original remote exec-file was lost. The execd_pathname is now stored in the inferior's program space as a REGISTRY field. All of the requisite mechanisms for this are defined in remote.c. gdb/gdbserver/ChangeLog: * linux-low.c (linux_mourn): Static declaration. (linux_arch_setup): Move in front of handle_extended_wait. (linux_arch_setup_thread): New function. (handle_extended_wait): Handle exec events. Call linux_arch_setup_thread. Make event_lwp argument a pointer-to-a-pointer. (check_zombie_leaders): Do not check stopped threads. (linux_low_ptrace_options): Add PTRACE_O_TRACEEXEC. (linux_low_filter_event): Add lwp and thread for exec'ing non-leader thread if leader thread has been deleted. Refactor code into linux_arch_setup_thread and call it. Pass child lwp pointer by reference to handle_extended_wait. (linux_wait_for_event_filtered): Update comment. (linux_wait_1): Prevent clobbering exec event status. (linux_supports_exec_events): New function. (linux_target_ops) <supports_exec_events>: Initialize new member. * lynx-low.c (lynx_target_ops) <supports_exec_events>: Initialize new member. * remote-utils.c (prepare_resume_reply): New stop reason 'exec'. * server.c (report_exec_events): New global variable. (handle_query): Handle qSupported query for exec-events feature. (captured_main): Initialize report_exec_events. * server.h (report_exec_events): Declare new global variable. * target.h (struct target_ops) <supports_exec_events>: New member. (target_supports_exec_events): New macro. * win32-low.c (win32_target_ops) <supports_exec_events>: Initialize new member. gdb/ChangeLog: * infrun.c (follow_exec): Use process-style ptid for exec message. Call add_inferior_with_spaces and target_follow_exec. * nat/linux-ptrace.c (linux_supports_traceexec): New function. * nat/linux-ptrace.h (linux_supports_traceexec): Declare. * remote.c (remote_pspace_data): New static variable. (remote_pspace_data_cleanup): New function. (get_remote_exec_file): New function. (set_remote_exec_file_1): New function. (set_remote_exec_file): New function. (show_remote_exec_file): New function. (remote_exec_file): Delete static variable. (anonymous enum) <PACKET_exec_event_feature> New enumeration constant. (remote_protocol_features): Add entry for exec-events feature. (remote_query_supported): Add client side of qSupported query for exec-events feature. (remote_follow_exec): New function. (remote_parse_stop_reply): Handle 'exec' stop reason. (extended_remote_run, extended_remote_create_inferior): Call get_remote_exec_file and set_remote_exec_file_1. (init_extended_remote_ops) <to_follow_exec>: Initialize new member. (_initialize_remote): Call register_program_space_data_with_cleanup. Call add_packet_config_cmd for remote exec-events feature. Modify call to add_setshow_string_noescape_cmd for exec-file to use new functions set_remote_exec_file and show_remote_exec_file. * target-debug.h, target-delegates.c: Regenerated. * target.c (target_follow_exec): New function. * target.h (struct target_ops) <to_follow_exec>: New member. (target_follow_exec): Declare new function.
2015-09-11 20:06:02 +02:00
if (handle_extended_wait (&child, wstat))
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
{
/* The event has been handled, so just return without
reporting it. */
return NULL;
}
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
}
if (linux_wstatus_maybe_breakpoint (wstat))
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
{
Handle MIPS Linux SIGTRAP siginfo.si_code values This unbreaks pending/delayed breakpoints handling, as well as hardware watchpoints, on MIPS. Ref: https://sourceware.org/ml/gdb-patches/2016-02/msg00681.html The MIPS kernel reports SI_KERNEL for all kernel generated traps, instead of TRAP_BRKPT / TRAP_HWBKPT, but GDB isn't aware of this. Basically, this commit: - Folds watchpoints logic into check_stopped_by_breakpoint, and renames it to save_stop_reason. - Adds GDB_ARCH_IS_TRAP_HWBKPT. - Makes MIPS set both GDB_ARCH_IS_TRAP_BRPT and GDB_ARCH_IS_TRAP_HWBKPT to SI_KERNEL. In save_stop_reason, we handle the case of the same si_code returning true for both TRAP_BRPT and TRAP_HWBKPT by looking at what the debug registers say. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-nat.c (save_sigtrap) Delete. (stop_wait_callback): Call save_stop_reason instead of save_sigtrap. (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Bits of save_sigtrap folded here. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_nat_filter_event): Call save_stop_reason instead of save_sigtrap. * nat/linux-ptrace.h: Check for both SI_KERNEL and TRAP_BRKPT si_code for MIPS. * nat/linux-ptrace.h: Fix "TRAP_HWBPT" typo in x86 table. Add comments on MIPS behavior. (GDB_ARCH_IS_TRAP_HWBKPT): Define for all archs. gdb/gdbserver/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-low.c (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_low_filter_event): Call save_stop_reason instead of check_stopped_by_breakpoint and check_stopped_by_watchpoint. Update comments. (linux_wait_1): Update comments.
2016-02-24 23:52:06 +01:00
if (save_stop_reason (child))
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
have_stop_pc = 1;
}
if (!have_stop_pc)
child->stop_pc = get_pc (child);
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
if (WIFSTOPPED (wstat) && WSTOPSIG (wstat) == SIGSTOP
&& child->stop_expected)
{
if (debug_threads)
debug_printf ("Expected stop.\n");
child->stop_expected = 0;
if (thread->last_resume_kind == resume_stop)
{
/* We want to report the stop to the core. Treat the
SIGSTOP as a normal event. */
if (debug_threads)
debug_printf ("LLW: resume_stop SIGSTOP caught for %s.\n",
target_pid_to_str (ptid_of (thread)));
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
}
else if (stopping_threads != NOT_STOPPING_THREADS)
{
/* Stopping threads. We don't want this SIGSTOP to end up
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
pending. */
if (debug_threads)
debug_printf ("LLW: SIGSTOP caught for %s "
"while stopping threads.\n",
target_pid_to_str (ptid_of (thread)));
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
return NULL;
}
else
{
/* This is a delayed SIGSTOP. Filter out the event. */
if (debug_threads)
debug_printf ("LLW: %s %s, 0, 0 (discard delayed SIGSTOP)\n",
child->stepping ? "step" : "continue",
target_pid_to_str (ptid_of (thread)));
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
resume_one_lwp (child, child->stepping, 0, NULL);
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
return NULL;
}
}
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
child->status_pending_p = 1;
child->status_pending = wstat;
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
return child;
}
gdbserver/linux-low: turn 'supports_hardware_single_step' into a method All the linux low targets except arm define the 'supports_hardware_single_step' op to return true. Hence, we override the method to return true in linux_process_target, and remove the definitions in all the linux low targets but arm. gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Remove the 'supports_hardware_single_step' linux target op and override the process_stratum_target's op definition in linux_process_target to return true. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <finish_step_over> <maybe_hw_step>: Declare. * linux-low.cc (can_hardware_single_step): Remove. (maybe_hw_step): Turn into... (linux_process_target::maybe_hw_step): ...this. (finish_step_over): Turn into... (linux_process_target::finish_step_over): ...this. (linux_process_target::supports_hardware_single_step): Update to return true. Update the callers below. (linux_process_target::single_step) (linux_process_target::resume_one_lwp_throw) * linux-arm-low.cc (class arm_target) <supports_hardware_single_step>: Declare. (arm_supports_hardware_single_step): Turn into... (arm_target::supports_hardware_single_step): ...this. (the_low_target): Remove the op field. * linux-x86-low.cc (x86_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-aarch64-low.cc (aarch64_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-bfin-low.cc (bfin_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-crisv32-low.cc (cris_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-m32r-low.cc (m32r_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-m68k-low.cc (m68k_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-ppc-low.cc (ppc_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-s390-low.cc (s390_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-sh-low.cc (sh_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-tic6x-low.cc (tic6x_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-tile-low.cc (tile_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-xtensa-low.cc (xtensa_supports_hardware_single_step): Remove. (the_low_target): Remove the op field.
2020-04-02 15:11:31 +02:00
bool
linux_process_target::maybe_hw_step (thread_info *thread)
Switch to current thread in finish_step_over This patch adds some sanity check that reinsert breakpoints must be there when doing step-over on software single step target. The check triggers an assert when running forking-threads-plus-breakpoint.exp on arm-linux target, gdb/gdbserver/linux-low.c:4714: A problem internal to GDBserver has been detected.^M int finish_step_over(lwp_info*): Assertion `has_reinsert_breakpoints ()' failed. the error happens when GDBserver has already resumed a thread of process A for step-over (and wait for it hitting reinsert breakpoint), but receives detach request for process B from GDB, which is shown in the backtrace below, (gdb) bt #2 0x000228aa in finish_step_over (lwp=0x12bbd98) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4703 #3 0x00025a50 in finish_step_over (lwp=0x12bbd98) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4749 #4 complete_ongoing_step_over () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4760 #5 linux_detach (pid=25228) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:1503 #6 0x00012bae in process_serial_event () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3974 #7 handle_serial_event (err=<optimized out>, client_data=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:4347 #8 0x00016d68 in handle_file_event (event_file_desc=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:429 #9 0x000173ea in process_event () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:184 #10 start_event_loop () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:547 #11 0x0000aa2c in captured_main (argv=<optimized out>, argc=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3719 #12 main (argc=<optimized out>, argv=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3804 the sanity check tries to find the reinsert breakpoint from process B, but nothing is found. It is wrong, we need to search in process A, since we started step-over of a thread of process A. (gdb) p lwp->thread->entry.id $3 = {pid = 25120, lwp = 25131, tid = 0} (gdb) p current_thread->entry.id $4 = {pid = 25228, lwp = 25228, tid = 0} This patch switched current_thread to the thread we are doing step-over in finish_step_over. gdb/gdbserver: 2016-06-17 Yao Qi <yao.qi@linaro.org> * linux-low.c (maybe_hw_step): New function. (linux_resume_one_lwp_throw): Call maybe_hw_step. (finish_step_over): Switch current_thread to lwp temporarily, and assert has_reinsert_breakpoints returns true. (proceed_one_lwp): Call maybe_hw_step. * mem-break.c (has_reinsert_breakpoints): New function. * mem-break.h (has_reinsert_breakpoints): Declare.
2016-06-17 11:25:12 +02:00
{
gdbserver/linux-low: turn 'supports_hardware_single_step' into a method All the linux low targets except arm define the 'supports_hardware_single_step' op to return true. Hence, we override the method to return true in linux_process_target, and remove the definitions in all the linux low targets but arm. gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Remove the 'supports_hardware_single_step' linux target op and override the process_stratum_target's op definition in linux_process_target to return true. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <finish_step_over> <maybe_hw_step>: Declare. * linux-low.cc (can_hardware_single_step): Remove. (maybe_hw_step): Turn into... (linux_process_target::maybe_hw_step): ...this. (finish_step_over): Turn into... (linux_process_target::finish_step_over): ...this. (linux_process_target::supports_hardware_single_step): Update to return true. Update the callers below. (linux_process_target::single_step) (linux_process_target::resume_one_lwp_throw) * linux-arm-low.cc (class arm_target) <supports_hardware_single_step>: Declare. (arm_supports_hardware_single_step): Turn into... (arm_target::supports_hardware_single_step): ...this. (the_low_target): Remove the op field. * linux-x86-low.cc (x86_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-aarch64-low.cc (aarch64_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-bfin-low.cc (bfin_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-crisv32-low.cc (cris_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-m32r-low.cc (m32r_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-m68k-low.cc (m68k_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-ppc-low.cc (ppc_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-s390-low.cc (s390_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-sh-low.cc (sh_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-tic6x-low.cc (tic6x_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-tile-low.cc (tile_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-xtensa-low.cc (xtensa_supports_hardware_single_step): Remove. (the_low_target): Remove the op field.
2020-04-02 15:11:31 +02:00
if (supports_hardware_single_step ())
return true;
Switch to current thread in finish_step_over This patch adds some sanity check that reinsert breakpoints must be there when doing step-over on software single step target. The check triggers an assert when running forking-threads-plus-breakpoint.exp on arm-linux target, gdb/gdbserver/linux-low.c:4714: A problem internal to GDBserver has been detected.^M int finish_step_over(lwp_info*): Assertion `has_reinsert_breakpoints ()' failed. the error happens when GDBserver has already resumed a thread of process A for step-over (and wait for it hitting reinsert breakpoint), but receives detach request for process B from GDB, which is shown in the backtrace below, (gdb) bt #2 0x000228aa in finish_step_over (lwp=0x12bbd98) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4703 #3 0x00025a50 in finish_step_over (lwp=0x12bbd98) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4749 #4 complete_ongoing_step_over () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4760 #5 linux_detach (pid=25228) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:1503 #6 0x00012bae in process_serial_event () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3974 #7 handle_serial_event (err=<optimized out>, client_data=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:4347 #8 0x00016d68 in handle_file_event (event_file_desc=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:429 #9 0x000173ea in process_event () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:184 #10 start_event_loop () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:547 #11 0x0000aa2c in captured_main (argv=<optimized out>, argc=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3719 #12 main (argc=<optimized out>, argv=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3804 the sanity check tries to find the reinsert breakpoint from process B, but nothing is found. It is wrong, we need to search in process A, since we started step-over of a thread of process A. (gdb) p lwp->thread->entry.id $3 = {pid = 25120, lwp = 25131, tid = 0} (gdb) p current_thread->entry.id $4 = {pid = 25228, lwp = 25228, tid = 0} This patch switched current_thread to the thread we are doing step-over in finish_step_over. gdb/gdbserver: 2016-06-17 Yao Qi <yao.qi@linaro.org> * linux-low.c (maybe_hw_step): New function. (linux_resume_one_lwp_throw): Call maybe_hw_step. (finish_step_over): Switch current_thread to lwp temporarily, and assert has_reinsert_breakpoints returns true. (proceed_one_lwp): Call maybe_hw_step. * mem-break.c (has_reinsert_breakpoints): New function. * mem-break.h (has_reinsert_breakpoints): Declare.
2016-06-17 11:25:12 +02:00
else
{
/* GDBserver must insert single-step breakpoint for software
Switch to current thread in finish_step_over This patch adds some sanity check that reinsert breakpoints must be there when doing step-over on software single step target. The check triggers an assert when running forking-threads-plus-breakpoint.exp on arm-linux target, gdb/gdbserver/linux-low.c:4714: A problem internal to GDBserver has been detected.^M int finish_step_over(lwp_info*): Assertion `has_reinsert_breakpoints ()' failed. the error happens when GDBserver has already resumed a thread of process A for step-over (and wait for it hitting reinsert breakpoint), but receives detach request for process B from GDB, which is shown in the backtrace below, (gdb) bt #2 0x000228aa in finish_step_over (lwp=0x12bbd98) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4703 #3 0x00025a50 in finish_step_over (lwp=0x12bbd98) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4749 #4 complete_ongoing_step_over () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4760 #5 linux_detach (pid=25228) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:1503 #6 0x00012bae in process_serial_event () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3974 #7 handle_serial_event (err=<optimized out>, client_data=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:4347 #8 0x00016d68 in handle_file_event (event_file_desc=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:429 #9 0x000173ea in process_event () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:184 #10 start_event_loop () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:547 #11 0x0000aa2c in captured_main (argv=<optimized out>, argc=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3719 #12 main (argc=<optimized out>, argv=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3804 the sanity check tries to find the reinsert breakpoint from process B, but nothing is found. It is wrong, we need to search in process A, since we started step-over of a thread of process A. (gdb) p lwp->thread->entry.id $3 = {pid = 25120, lwp = 25131, tid = 0} (gdb) p current_thread->entry.id $4 = {pid = 25228, lwp = 25228, tid = 0} This patch switched current_thread to the thread we are doing step-over in finish_step_over. gdb/gdbserver: 2016-06-17 Yao Qi <yao.qi@linaro.org> * linux-low.c (maybe_hw_step): New function. (linux_resume_one_lwp_throw): Call maybe_hw_step. (finish_step_over): Switch current_thread to lwp temporarily, and assert has_reinsert_breakpoints returns true. (proceed_one_lwp): Call maybe_hw_step. * mem-break.c (has_reinsert_breakpoints): New function. * mem-break.h (has_reinsert_breakpoints): Declare.
2016-06-17 11:25:12 +02:00
single step. */
gdb_assert (has_single_step_breakpoints (thread));
gdbserver/linux-low: turn 'supports_hardware_single_step' into a method All the linux low targets except arm define the 'supports_hardware_single_step' op to return true. Hence, we override the method to return true in linux_process_target, and remove the definitions in all the linux low targets but arm. gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Remove the 'supports_hardware_single_step' linux target op and override the process_stratum_target's op definition in linux_process_target to return true. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <finish_step_over> <maybe_hw_step>: Declare. * linux-low.cc (can_hardware_single_step): Remove. (maybe_hw_step): Turn into... (linux_process_target::maybe_hw_step): ...this. (finish_step_over): Turn into... (linux_process_target::finish_step_over): ...this. (linux_process_target::supports_hardware_single_step): Update to return true. Update the callers below. (linux_process_target::single_step) (linux_process_target::resume_one_lwp_throw) * linux-arm-low.cc (class arm_target) <supports_hardware_single_step>: Declare. (arm_supports_hardware_single_step): Turn into... (arm_target::supports_hardware_single_step): ...this. (the_low_target): Remove the op field. * linux-x86-low.cc (x86_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-aarch64-low.cc (aarch64_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-bfin-low.cc (bfin_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-crisv32-low.cc (cris_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-m32r-low.cc (m32r_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-m68k-low.cc (m68k_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-ppc-low.cc (ppc_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-s390-low.cc (s390_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-sh-low.cc (sh_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-tic6x-low.cc (tic6x_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-tile-low.cc (tile_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-xtensa-low.cc (xtensa_supports_hardware_single_step): Remove. (the_low_target): Remove the op field.
2020-04-02 15:11:31 +02:00
return false;
Switch to current thread in finish_step_over This patch adds some sanity check that reinsert breakpoints must be there when doing step-over on software single step target. The check triggers an assert when running forking-threads-plus-breakpoint.exp on arm-linux target, gdb/gdbserver/linux-low.c:4714: A problem internal to GDBserver has been detected.^M int finish_step_over(lwp_info*): Assertion `has_reinsert_breakpoints ()' failed. the error happens when GDBserver has already resumed a thread of process A for step-over (and wait for it hitting reinsert breakpoint), but receives detach request for process B from GDB, which is shown in the backtrace below, (gdb) bt #2 0x000228aa in finish_step_over (lwp=0x12bbd98) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4703 #3 0x00025a50 in finish_step_over (lwp=0x12bbd98) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4749 #4 complete_ongoing_step_over () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4760 #5 linux_detach (pid=25228) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:1503 #6 0x00012bae in process_serial_event () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3974 #7 handle_serial_event (err=<optimized out>, client_data=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:4347 #8 0x00016d68 in handle_file_event (event_file_desc=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:429 #9 0x000173ea in process_event () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:184 #10 start_event_loop () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:547 #11 0x0000aa2c in captured_main (argv=<optimized out>, argc=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3719 #12 main (argc=<optimized out>, argv=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3804 the sanity check tries to find the reinsert breakpoint from process B, but nothing is found. It is wrong, we need to search in process A, since we started step-over of a thread of process A. (gdb) p lwp->thread->entry.id $3 = {pid = 25120, lwp = 25131, tid = 0} (gdb) p current_thread->entry.id $4 = {pid = 25228, lwp = 25228, tid = 0} This patch switched current_thread to the thread we are doing step-over in finish_step_over. gdb/gdbserver: 2016-06-17 Yao Qi <yao.qi@linaro.org> * linux-low.c (maybe_hw_step): New function. (linux_resume_one_lwp_throw): Call maybe_hw_step. (finish_step_over): Switch current_thread to lwp temporarily, and assert has_reinsert_breakpoints returns true. (proceed_one_lwp): Call maybe_hw_step. * mem-break.c (has_reinsert_breakpoints): New function. * mem-break.h (has_reinsert_breakpoints): Declare.
2016-06-17 11:25:12 +02:00
}
}
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
void
linux_process_target::resume_stopped_resumed_lwps (thread_info *thread)
Linux: don't resume new LWPs until we've pulled all events out of the kernel Since the starvation avoidance series (https://sourceware.org/ml/gdb-patches/2014-12/msg00631.html), both GDB and GDBserver pull all events out of ptrace before deciding which event to process. There's one problem with that though. Because we resume new threads immediately when we see a PTRACE_EVENT_CLONE event, if the program constantly spawns threads fast enough, new threads can spawn threads faster we can pull events out of the kernel, and thus we'd get stuck in an infinite loop, never returning any event to the core to process. I occasionally see this happen with the attach-many-short-lived-threads.exp test against gdbserver. The fix is to delay resuming new threads until we've pulled out all events out of the kernel. On native, we already have the resume_stopped_resumed_lwps function that knows to resume LWPs that are stopped with no event to report to the core. So the patch just adds another use. GDBserver didn't have the equivalent yet, so the patch adds one. Tested on x86_64 Fedora 20, native and gdbserver (remote and extended-remote). gdb/gdbserver/ChangeLog: 2015-02-04 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Don't resume LWPs here. (resume_stopped_resumed_lwps): New function. (linux_wait_for_event_filtered): Use it. gdb/ChangeLog: 2015-02-04 Pedro Alves <palves@redhat.com> * linux-nat.c (handle_extended_wait): Don't resume LWPs here. (wait_lwp): Don't call wait_lwp if linux_handle_extended_wait returns true. (resume_stopped_resumed_lwps): Don't check whether the thread is marked as executing. (linux_nat_wait_1): Use resume_stopped_resumed_lwps.
2015-02-04 19:13:28 +01:00
{
struct lwp_info *lp = get_thread_lwp (thread);
if (lp->stopped
gdbserver: Fix non-stop / fork / step-over issues Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html This adds a test that has a multithreaded program have several threads continuously fork, while another thread continuously steps over a breakpoint. This exposes several intertwined issues, which this patch addresses: - When we're stopping and suspending threads, some thread may fork, and we missed setting its suspend count to 1, like we do when a new clone/thread is detected. When we next unsuspend threads, the fork child's suspend count goes below 0, which is bogus and fails an assertion. - If a step-over is cancelled because a signal arrives, but then gdb is not interested in the signal, we pass the signal straight back to the inferior. However, we miss that we need to re-increment the suspend counts of all other threads that had been paused for the step-over. As a result, other threads indefinitely end up stuck stopped. - If a detach request comes in just while gdbserver is handling a step-over (in the test at hand, this is GDB detaching the fork child), gdbserver internal errors in stabilize_thread's helpers, which assert that all thread's suspend counts are 0 (otherwise we wouldn't be able to move threads out of the jump pads). The suspend counts aren't 0 while a step-over is in progress, because all threads but the one stepping past the breakpoint must remain paused until the step-over finishes and the breakpoint can be reinserted. - Occasionally, we see "BAD - reinserting but not stepping." being output (from within linux_resume_one_lwp_throw). That was because GDB pokes memory while gdbserver is busy with a step-over, and that suspends threads, and then re-resumes them with proceed_one_lwp, which missed another reason to tell linux_resume_one_lwp that the thread should be set back to stepping. - In a couple places, we were resuming threads that are meant to be suspended. E.g., when a vCont;c/s request for thread B comes in just while gdbserver is stepping thread A past a breakpoint. The resume for thread B must be deferred until the step-over finishes. - The test runs with both "set detach-on-fork" on and off. When off, it exercises the case of GDB detaching the fork child explicitly. When on, it exercises the case of gdb resuming the child explicitly. In the "off" case, gdb seems to exponentially become slower as new inferiors are created. This is _very_ noticeable as with only 100 inferiors gdb is crawling already, which makes the test take quite a bit to run. For that reason, I've disabled the "off" variant for now. gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * target/waitstatus.h (enum target_stop_reason) <TARGET_STOPPED_BY_SINGLE_STEP>: New value. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the fork child's suspend count if stopping and suspending threads. (check_stopped_by_breakpoint): If stopped by trace, set the LWP's stop reason to TARGET_STOPPED_BY_SINGLE_STEP. (linux_detach): Complete an ongoing step-over. (lwp_suspended_inc, lwp_suspended_decr): New functions. Use throughout. (resume_stopped_resumed_lwps): Don't resume a suspended thread. (linux_wait_1): If passing a signal to the inferior after finishing a step-over, unsuspend and re-resume all lwps. If we see a single-step event but the thread should be continuing, don't pass the trap to gdb. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use internal_error instead of gdb_assert. (enqueue_pending_signal): New function. (check_ptrace_stopped_lwp_gone): Add debug output. (start_step_over): Use internal_error instead of gdb_assert. (complete_ongoing_step_over): New function. (linux_resume_one_thread): Don't resume a suspended thread. (proceed_one_lwp): If the LWP is stepping over a breakpoint, reset it stepping. gdb/testsuite/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * gdb.threads/forking-threads-plus-breakpoint.exp: New file. * gdb.threads/forking-threads-plus-breakpoint.c: New file.
2015-08-06 11:30:18 +02:00
&& !lp->suspended
Linux: don't resume new LWPs until we've pulled all events out of the kernel Since the starvation avoidance series (https://sourceware.org/ml/gdb-patches/2014-12/msg00631.html), both GDB and GDBserver pull all events out of ptrace before deciding which event to process. There's one problem with that though. Because we resume new threads immediately when we see a PTRACE_EVENT_CLONE event, if the program constantly spawns threads fast enough, new threads can spawn threads faster we can pull events out of the kernel, and thus we'd get stuck in an infinite loop, never returning any event to the core to process. I occasionally see this happen with the attach-many-short-lived-threads.exp test against gdbserver. The fix is to delay resuming new threads until we've pulled out all events out of the kernel. On native, we already have the resume_stopped_resumed_lwps function that knows to resume LWPs that are stopped with no event to report to the core. So the patch just adds another use. GDBserver didn't have the equivalent yet, so the patch adds one. Tested on x86_64 Fedora 20, native and gdbserver (remote and extended-remote). gdb/gdbserver/ChangeLog: 2015-02-04 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Don't resume LWPs here. (resume_stopped_resumed_lwps): New function. (linux_wait_for_event_filtered): Use it. gdb/ChangeLog: 2015-02-04 Pedro Alves <palves@redhat.com> * linux-nat.c (handle_extended_wait): Don't resume LWPs here. (wait_lwp): Don't call wait_lwp if linux_handle_extended_wait returns true. (resume_stopped_resumed_lwps): Don't check whether the thread is marked as executing. (linux_nat_wait_1): Use resume_stopped_resumed_lwps.
2015-02-04 19:13:28 +01:00
&& !lp->status_pending_p
&& thread->last_status.kind == TARGET_WAITKIND_IGNORE)
{
int step = 0;
if (thread->last_resume_kind == resume_step)
step = maybe_hw_step (thread);
Linux: don't resume new LWPs until we've pulled all events out of the kernel Since the starvation avoidance series (https://sourceware.org/ml/gdb-patches/2014-12/msg00631.html), both GDB and GDBserver pull all events out of ptrace before deciding which event to process. There's one problem with that though. Because we resume new threads immediately when we see a PTRACE_EVENT_CLONE event, if the program constantly spawns threads fast enough, new threads can spawn threads faster we can pull events out of the kernel, and thus we'd get stuck in an infinite loop, never returning any event to the core to process. I occasionally see this happen with the attach-many-short-lived-threads.exp test against gdbserver. The fix is to delay resuming new threads until we've pulled out all events out of the kernel. On native, we already have the resume_stopped_resumed_lwps function that knows to resume LWPs that are stopped with no event to report to the core. So the patch just adds another use. GDBserver didn't have the equivalent yet, so the patch adds one. Tested on x86_64 Fedora 20, native and gdbserver (remote and extended-remote). gdb/gdbserver/ChangeLog: 2015-02-04 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Don't resume LWPs here. (resume_stopped_resumed_lwps): New function. (linux_wait_for_event_filtered): Use it. gdb/ChangeLog: 2015-02-04 Pedro Alves <palves@redhat.com> * linux-nat.c (handle_extended_wait): Don't resume LWPs here. (wait_lwp): Don't call wait_lwp if linux_handle_extended_wait returns true. (resume_stopped_resumed_lwps): Don't check whether the thread is marked as executing. (linux_nat_wait_1): Use resume_stopped_resumed_lwps.
2015-02-04 19:13:28 +01:00
if (debug_threads)
debug_printf ("RSRL: resuming stopped-resumed LWP %s at %s: step=%d\n",
target_pid_to_str (ptid_of (thread)),
paddress (lp->stop_pc),
step);
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
resume_one_lwp (lp, step, GDB_SIGNAL_0, NULL);
Linux: don't resume new LWPs until we've pulled all events out of the kernel Since the starvation avoidance series (https://sourceware.org/ml/gdb-patches/2014-12/msg00631.html), both GDB and GDBserver pull all events out of ptrace before deciding which event to process. There's one problem with that though. Because we resume new threads immediately when we see a PTRACE_EVENT_CLONE event, if the program constantly spawns threads fast enough, new threads can spawn threads faster we can pull events out of the kernel, and thus we'd get stuck in an infinite loop, never returning any event to the core to process. I occasionally see this happen with the attach-many-short-lived-threads.exp test against gdbserver. The fix is to delay resuming new threads until we've pulled out all events out of the kernel. On native, we already have the resume_stopped_resumed_lwps function that knows to resume LWPs that are stopped with no event to report to the core. So the patch just adds another use. GDBserver didn't have the equivalent yet, so the patch adds one. Tested on x86_64 Fedora 20, native and gdbserver (remote and extended-remote). gdb/gdbserver/ChangeLog: 2015-02-04 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Don't resume LWPs here. (resume_stopped_resumed_lwps): New function. (linux_wait_for_event_filtered): Use it. gdb/ChangeLog: 2015-02-04 Pedro Alves <palves@redhat.com> * linux-nat.c (handle_extended_wait): Don't resume LWPs here. (wait_lwp): Don't call wait_lwp if linux_handle_extended_wait returns true. (resume_stopped_resumed_lwps): Don't check whether the thread is marked as executing. (linux_nat_wait_1): Use resume_stopped_resumed_lwps.
2015-02-04 19:13:28 +01:00
}
}
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
int
linux_process_target::wait_for_event_filtered (ptid_t wait_ptid,
ptid_t filter_ptid,
int *wstatp, int options)
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
{
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
struct thread_info *event_thread;
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
struct lwp_info *event_child, *requested_child;
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
sigset_t block_mask, prev_mask;
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
retry:
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
/* N.B. event_thread points to the thread_info struct that contains
event_child. Keep them in sync. */
event_thread = NULL;
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
event_child = NULL;
requested_child = NULL;
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
/* Check for a lwp with a pending status. */
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
2018-06-11 22:45:22 +02:00
if (filter_ptid == minus_one_ptid || filter_ptid.is_pid ())
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
{
event_thread = find_thread_in_random ([&] (thread_info *thread)
{
return status_pending_p_callback (thread, filter_ptid);
});
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
if (event_thread != NULL)
event_child = get_thread_lwp (event_thread);
if (debug_threads && event_thread)
debug_printf ("Got a pending child %ld\n", lwpid_of (event_thread));
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
}
2018-06-11 22:45:22 +02:00
else if (filter_ptid != null_ptid)
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
{
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
requested_child = find_lwp_pid (filter_ptid);
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
if (stopping_threads == NOT_STOPPING_THREADS
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
&& requested_child->status_pending_p
&& (requested_child->collecting_fast_tracepoint
!= fast_tpoint_collect_result::not_collecting))
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
{
enqueue_one_deferred_signal (requested_child,
&requested_child->status_pending);
requested_child->status_pending_p = 0;
requested_child->status_pending = 0;
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
resume_one_lwp (requested_child, 0, 0, NULL);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
}
if (requested_child->suspended
&& requested_child->status_pending_p)
{
internal_error (__FILE__, __LINE__,
"requesting an event out of a"
" suspended child?");
}
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
if (requested_child->status_pending_p)
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
{
event_child = requested_child;
event_thread = get_lwp_thread (event_child);
}
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
}
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
if (event_child != NULL)
{
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Got an event from pending child %ld (%04x)\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
lwpid_of (event_thread), event_child->status_pending);
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
*wstatp = event_child->status_pending;
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
event_child->status_pending_p = 0;
event_child->status_pending = 0;
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
current_thread = event_thread;
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
return lwpid_of (event_thread);
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
}
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
/* But if we don't find a pending event, we'll have to wait.
We only enter this loop if no process has a pending wait status.
Thus any action taken in response to a wait status inside this
loop is responding as soon as we detect the status, not after any
pending events. */
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
/* Make sure SIGCHLD is blocked until the sigsuspend below. Block
all signals while here. */
sigfillset (&block_mask);
Add RAII class for blocking gdb signals This adds configury support and an RAII class that can be used to temporarily block signals that are used by gdb. (This class is not used in this patch, but it split out for easier review.) The idea of this patch is that these signals should only be delivered to the main thread. So, when creating a background thread, they are temporarily blocked; the blocked state is inherited by the new thread. The sigprocmask man page says: The use of sigprocmask() is unspecified in a multithreaded process; see pthread_sigmask(3). This patch changes gdb to use pthread_sigmask when appropriate, by introducing a convenience define. I've updated gdbserver as well, because I had to touch gdbsupport, and because the threading patches will make it link against the thread library. I chose not to touch the NTO code, because I don't know anything about that platform and because I cannot test it. Finally, this modifies an existing spot in the Guile layer to use the new facility. gdb/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * gdbsupport/signals-state-save-restore.c (original_signal_mask): Remove comment. (save_original_signals_state, restore_original_signals_state): Use gdb_sigmask. * linux-nat.c (block_child_signals, restore_child_signals_mask) (_initialize_linux_nat): Use gdb_sigmask. * guile/guile.c (_initialize_guile): Use block_signals. * Makefile.in (HFILES_NO_SRCDIR): Add gdb-sigmask.h. * gdbsupport/gdb-sigmask.h: New file. * event-top.c (async_sigtstp_handler): Use gdb_sigmask. * cp-support.c (gdb_demangle): Use gdb_sigmask. * gdbsupport/common.m4 (GDB_AC_COMMON): Check for pthread_sigmask. * configure, config.in: Rebuild. * gdbsupport/block-signals.h: New file. gdb/gdbserver/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * remote-utils.c (block_unblock_async_io): Use gdb_sigmask. * linux-low.c (linux_wait_for_event_filtered, linux_async): Use gdb_sigmask. * configure, config.in: Rebuild. Change-Id: If3f37dc57dd859c226e9e4d79458a0514746e8c6
2019-09-29 16:50:15 +02:00
gdb_sigmask (SIG_BLOCK, &block_mask, &prev_mask);
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
/* Always pull all events out of the kernel. We'll randomly select
an event LWP out of all that have events, to prevent
starvation. */
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
while (event_child == NULL)
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
{
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
pid_t ret = 0;
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
/* Always use -1 and WNOHANG, due to couple of a kernel/ptrace
quirks:
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
- If the thread group leader exits while other threads in the
thread group still exist, waitpid(TGID, ...) hangs. That
waitpid won't return an exit status until the other threads
in the group are reaped.
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
- When a non-leader thread execs, that thread just vanishes
without reporting an exit (so we'd hang if we waited for it
explicitly in that case). The exec event is reported to
Extended-remote follow-exec This patch implements support for exec events on extended-remote Linux targets. Follow-exec-mode and rerun behave as expected. Catchpoints and test updates are implemented in subsequent patches. This patch was derived from a patch posted last October: https://sourceware.org/ml/gdb-patches/2014-10/msg00877.html. It was originally based on some work done by Luis Machado in 2013. IMPLEMENTATION ---------------- Exec events are enabled via ptrace options. When an exec event is detected by gdbserver, the existing process data, along with all its associated lwp and thread data, is deleted and replaced by data for a new single-threaded process. The new process data is initialized with the appropriate parts of the state of the execing process. This approach takes care of several potential pitfalls, including: * deleting the data for an execing non-leader thread before any wait/sigsuspend occurs * correctly initializing the architecture of the execed process We then report the exec event using a new RSP stop reason, "exec". When GDB receives an "exec" event, it saves the status in the event structure's target_waitstatus field, like what is done for remote fork events. Because the original and execed programs may have different architectures, we skip parsing the section of the stop reply packet that contains register data. The register data will be retrieved later after the inferior's architecture has been set up by infrun.c:follow_exec. At that point the exec event is handled by the existing event handling in GDB. However, a few changes were necessary so that infrun.c:follow_exec could accommodate the remote target. * Where follow-exec-mode "new" is handled, we now call add_inferior_with_spaces instead of add_inferior with separate calls to set up the program and address spaces. The motivation for this is that add_inferior_with_spaces also sets up the initial architecture for the inferior, which is needed later by target_find_description when it calls target_gdbarch. * We call a new target function, target_follow_exec. This function allows us to store the execd_pathname in the inferior, instead of using the static string remote_exec_file from remote.c. The static string didn't work for follow-exec-mode "new", since once you switched to the execed program, the original remote exec-file was lost. The execd_pathname is now stored in the inferior's program space as a REGISTRY field. All of the requisite mechanisms for this are defined in remote.c. gdb/gdbserver/ChangeLog: * linux-low.c (linux_mourn): Static declaration. (linux_arch_setup): Move in front of handle_extended_wait. (linux_arch_setup_thread): New function. (handle_extended_wait): Handle exec events. Call linux_arch_setup_thread. Make event_lwp argument a pointer-to-a-pointer. (check_zombie_leaders): Do not check stopped threads. (linux_low_ptrace_options): Add PTRACE_O_TRACEEXEC. (linux_low_filter_event): Add lwp and thread for exec'ing non-leader thread if leader thread has been deleted. Refactor code into linux_arch_setup_thread and call it. Pass child lwp pointer by reference to handle_extended_wait. (linux_wait_for_event_filtered): Update comment. (linux_wait_1): Prevent clobbering exec event status. (linux_supports_exec_events): New function. (linux_target_ops) <supports_exec_events>: Initialize new member. * lynx-low.c (lynx_target_ops) <supports_exec_events>: Initialize new member. * remote-utils.c (prepare_resume_reply): New stop reason 'exec'. * server.c (report_exec_events): New global variable. (handle_query): Handle qSupported query for exec-events feature. (captured_main): Initialize report_exec_events. * server.h (report_exec_events): Declare new global variable. * target.h (struct target_ops) <supports_exec_events>: New member. (target_supports_exec_events): New macro. * win32-low.c (win32_target_ops) <supports_exec_events>: Initialize new member. gdb/ChangeLog: * infrun.c (follow_exec): Use process-style ptid for exec message. Call add_inferior_with_spaces and target_follow_exec. * nat/linux-ptrace.c (linux_supports_traceexec): New function. * nat/linux-ptrace.h (linux_supports_traceexec): Declare. * remote.c (remote_pspace_data): New static variable. (remote_pspace_data_cleanup): New function. (get_remote_exec_file): New function. (set_remote_exec_file_1): New function. (set_remote_exec_file): New function. (show_remote_exec_file): New function. (remote_exec_file): Delete static variable. (anonymous enum) <PACKET_exec_event_feature> New enumeration constant. (remote_protocol_features): Add entry for exec-events feature. (remote_query_supported): Add client side of qSupported query for exec-events feature. (remote_follow_exec): New function. (remote_parse_stop_reply): Handle 'exec' stop reason. (extended_remote_run, extended_remote_create_inferior): Call get_remote_exec_file and set_remote_exec_file_1. (init_extended_remote_ops) <to_follow_exec>: Initialize new member. (_initialize_remote): Call register_program_space_data_with_cleanup. Call add_packet_config_cmd for remote exec-events feature. Modify call to add_setshow_string_noescape_cmd for exec-file to use new functions set_remote_exec_file and show_remote_exec_file. * target-debug.h, target-delegates.c: Regenerated. * target.c (target_follow_exec): New function. * target.h (struct target_ops) <to_follow_exec>: New member. (target_follow_exec): Declare new function.
2015-09-11 20:06:02 +02:00
the TGID pid. */
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
errno = 0;
ret = my_waitpid (-1, wstatp, options | WNOHANG);
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
if (debug_threads)
debug_printf ("LWFE: waitpid(-1, ...) returned %d, %s\n",
ret, errno ? safe_strerror (errno) : "ERRNO-OK");
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
if (ret > 0)
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
{
if (debug_threads)
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
{
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
debug_printf ("LLW: waitpid %ld received %s\n",
(long) ret, status_to_str (*wstatp));
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
}
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
/* Filter all events. IOW, leave all events pending. We'll
randomly select an event LWP out of all that have events
below. */
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
filter_event (ret, *wstatp);
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
/* Retry until nothing comes out of waitpid. A single
SIGCHLD can indicate more than one child stopped. */
continue;
}
Linux: don't resume new LWPs until we've pulled all events out of the kernel Since the starvation avoidance series (https://sourceware.org/ml/gdb-patches/2014-12/msg00631.html), both GDB and GDBserver pull all events out of ptrace before deciding which event to process. There's one problem with that though. Because we resume new threads immediately when we see a PTRACE_EVENT_CLONE event, if the program constantly spawns threads fast enough, new threads can spawn threads faster we can pull events out of the kernel, and thus we'd get stuck in an infinite loop, never returning any event to the core to process. I occasionally see this happen with the attach-many-short-lived-threads.exp test against gdbserver. The fix is to delay resuming new threads until we've pulled out all events out of the kernel. On native, we already have the resume_stopped_resumed_lwps function that knows to resume LWPs that are stopped with no event to report to the core. So the patch just adds another use. GDBserver didn't have the equivalent yet, so the patch adds one. Tested on x86_64 Fedora 20, native and gdbserver (remote and extended-remote). gdb/gdbserver/ChangeLog: 2015-02-04 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Don't resume LWPs here. (resume_stopped_resumed_lwps): New function. (linux_wait_for_event_filtered): Use it. gdb/ChangeLog: 2015-02-04 Pedro Alves <palves@redhat.com> * linux-nat.c (handle_extended_wait): Don't resume LWPs here. (wait_lwp): Don't call wait_lwp if linux_handle_extended_wait returns true. (resume_stopped_resumed_lwps): Don't check whether the thread is marked as executing. (linux_nat_wait_1): Use resume_stopped_resumed_lwps.
2015-02-04 19:13:28 +01:00
/* Now that we've pulled all events out of the kernel, resume
LWPs that don't have an interesting event to report. */
if (stopping_threads == NOT_STOPPING_THREADS)
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
for_each_thread ([this] (thread_info *thread)
{
resume_stopped_resumed_lwps (thread);
});
Linux: don't resume new LWPs until we've pulled all events out of the kernel Since the starvation avoidance series (https://sourceware.org/ml/gdb-patches/2014-12/msg00631.html), both GDB and GDBserver pull all events out of ptrace before deciding which event to process. There's one problem with that though. Because we resume new threads immediately when we see a PTRACE_EVENT_CLONE event, if the program constantly spawns threads fast enough, new threads can spawn threads faster we can pull events out of the kernel, and thus we'd get stuck in an infinite loop, never returning any event to the core to process. I occasionally see this happen with the attach-many-short-lived-threads.exp test against gdbserver. The fix is to delay resuming new threads until we've pulled out all events out of the kernel. On native, we already have the resume_stopped_resumed_lwps function that knows to resume LWPs that are stopped with no event to report to the core. So the patch just adds another use. GDBserver didn't have the equivalent yet, so the patch adds one. Tested on x86_64 Fedora 20, native and gdbserver (remote and extended-remote). gdb/gdbserver/ChangeLog: 2015-02-04 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Don't resume LWPs here. (resume_stopped_resumed_lwps): New function. (linux_wait_for_event_filtered): Use it. gdb/ChangeLog: 2015-02-04 Pedro Alves <palves@redhat.com> * linux-nat.c (handle_extended_wait): Don't resume LWPs here. (wait_lwp): Don't call wait_lwp if linux_handle_extended_wait returns true. (resume_stopped_resumed_lwps): Don't check whether the thread is marked as executing. (linux_nat_wait_1): Use resume_stopped_resumed_lwps.
2015-02-04 19:13:28 +01:00
/* ... and find an LWP with a status to report to the core, if
any. */
event_thread = find_thread_in_random ([&] (thread_info *thread)
{
return status_pending_p_callback (thread, filter_ptid);
});
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
if (event_thread != NULL)
{
event_child = get_thread_lwp (event_thread);
*wstatp = event_child->status_pending;
event_child->status_pending_p = 0;
event_child->status_pending = 0;
break;
}
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
/* Check for zombie thread group leaders. Those can't be reaped
until all other threads in the thread group are. */
check_zombie_leaders ();
auto not_stopped = [&] (thread_info *thread)
{
return not_stopped_callback (thread, wait_ptid);
};
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
/* If there are no resumed children left in the set of LWPs we
want to wait for, bail. We can't just block in
waitpid/sigsuspend, because lwps might have been left stopped
in trace-stop state, and we'd be stuck forever waiting for
their status to change (which would only happen if we resumed
them). Even if WNOHANG is set, this return code is preferred
over 0 (below), as it is more detailed. */
if (find_thread (not_stopped) == NULL)
{
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
if (debug_threads)
debug_printf ("LLW: exit (no unwaited-for LWP)\n");
Add RAII class for blocking gdb signals This adds configury support and an RAII class that can be used to temporarily block signals that are used by gdb. (This class is not used in this patch, but it split out for easier review.) The idea of this patch is that these signals should only be delivered to the main thread. So, when creating a background thread, they are temporarily blocked; the blocked state is inherited by the new thread. The sigprocmask man page says: The use of sigprocmask() is unspecified in a multithreaded process; see pthread_sigmask(3). This patch changes gdb to use pthread_sigmask when appropriate, by introducing a convenience define. I've updated gdbserver as well, because I had to touch gdbsupport, and because the threading patches will make it link against the thread library. I chose not to touch the NTO code, because I don't know anything about that platform and because I cannot test it. Finally, this modifies an existing spot in the Guile layer to use the new facility. gdb/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * gdbsupport/signals-state-save-restore.c (original_signal_mask): Remove comment. (save_original_signals_state, restore_original_signals_state): Use gdb_sigmask. * linux-nat.c (block_child_signals, restore_child_signals_mask) (_initialize_linux_nat): Use gdb_sigmask. * guile/guile.c (_initialize_guile): Use block_signals. * Makefile.in (HFILES_NO_SRCDIR): Add gdb-sigmask.h. * gdbsupport/gdb-sigmask.h: New file. * event-top.c (async_sigtstp_handler): Use gdb_sigmask. * cp-support.c (gdb_demangle): Use gdb_sigmask. * gdbsupport/common.m4 (GDB_AC_COMMON): Check for pthread_sigmask. * configure, config.in: Rebuild. * gdbsupport/block-signals.h: New file. gdb/gdbserver/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * remote-utils.c (block_unblock_async_io): Use gdb_sigmask. * linux-low.c (linux_wait_for_event_filtered, linux_async): Use gdb_sigmask. * configure, config.in: Rebuild. Change-Id: If3f37dc57dd859c226e9e4d79458a0514746e8c6
2019-09-29 16:50:15 +02:00
gdb_sigmask (SIG_SETMASK, &prev_mask, NULL);
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
return -1;
}
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
/* No interesting event to report to the caller. */
if ((options & WNOHANG))
* inferiors.c (change_inferior_id): Delete. (add_pid_to_list, pull_pid_from_list): New. * linux-low.c (PTRACE_SETOPTIONS, PTRACE_GETEVENTMSG) (PTRACE_O_TRACESYSGOOD, PTRACE_O_TRACEFORK, PTRACE_O_TRACEVFORK) (PTRACE_O_TRACECLONE, PTRACE_O_TRACEEXEC, PTRACE_O_TRACEVFORKDONE) (PTRACE_O_TRACEEXIT, PTRACE_EVENT_FORK, PTRACE_EVENT_VFORK) (PTRACE_EVENT_CLONE, PTRACE_EVENT_EXEC, PTRACE_EVENT_VFORK_DONE) (PTRACE_EVENT_EXIT, __WALL): Provide default definitions. (stopped_pids, thread_db_active, must_set_ptrace_flags): New variables. (using_threads): Always set to 1. (handle_extended_wait): New. (add_process): Do not set TID. (linux_create_inferior): Set must_set_ptrace_flags. (linux_attach_lwp): Remove TID argument. Do not check using_threads. Use PTRACE_SETOPTIONS. Call new_thread_notify. Update all callers. (linux_thread_alive): Rename TID argument to LWPID. (linux_wait_for_process): Handle unknown processes. Do not use TID. (linux_wait_for_event): Do not use TID or check using_threads. Update call to dead_thread_notify. Call handle_extended_wait. (linux_create_inferior): Use PTRACE_SETOPTIONS. (send_sigstop): Delete sigstop_sent. (wait_for_sigstop): Avoid TID. (linux_supports_tracefork_flag, linux_tracefork_child, my_waitpid) (linux_test_for_tracefork): New. (linux_lookup_signals): Use thread_db_active and linux_supports_tracefork_flag. (initialize_low): Use thread_db_active and linux_test_for_tracefork. * linux-low.h (get_process_thread): Avoid TID. (struct process_ifo): Move thread_known and tid to the end. Remove sigstop_sent. (linux_attach_lwp, thread_db_init): Update prototypes. * server.h (change_inferior_id): Delete prototype. (add_pid_to_list, pull_pid_from_list): New prototypes. * thread-db.c (thread_db_use_events): New. (find_first_thread): Rename to... (find_one_thread): ...this. Update callers and messages. Do not call fatal. Check thread_db_use_events. Do not call change_inferior_id or new_thread_notify. (maybe_attach_thread): Update. Do not call new_thread_notify. (thread_db_init): Set thread_db_use_events. Check use_events. * utils.c (fatal, warning): Correct message prefix.
2007-10-23 22:05:03 +02:00
{
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
if (debug_threads)
debug_printf ("WNOHANG set, no event found\n");
Add RAII class for blocking gdb signals This adds configury support and an RAII class that can be used to temporarily block signals that are used by gdb. (This class is not used in this patch, but it split out for easier review.) The idea of this patch is that these signals should only be delivered to the main thread. So, when creating a background thread, they are temporarily blocked; the blocked state is inherited by the new thread. The sigprocmask man page says: The use of sigprocmask() is unspecified in a multithreaded process; see pthread_sigmask(3). This patch changes gdb to use pthread_sigmask when appropriate, by introducing a convenience define. I've updated gdbserver as well, because I had to touch gdbsupport, and because the threading patches will make it link against the thread library. I chose not to touch the NTO code, because I don't know anything about that platform and because I cannot test it. Finally, this modifies an existing spot in the Guile layer to use the new facility. gdb/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * gdbsupport/signals-state-save-restore.c (original_signal_mask): Remove comment. (save_original_signals_state, restore_original_signals_state): Use gdb_sigmask. * linux-nat.c (block_child_signals, restore_child_signals_mask) (_initialize_linux_nat): Use gdb_sigmask. * guile/guile.c (_initialize_guile): Use block_signals. * Makefile.in (HFILES_NO_SRCDIR): Add gdb-sigmask.h. * gdbsupport/gdb-sigmask.h: New file. * event-top.c (async_sigtstp_handler): Use gdb_sigmask. * cp-support.c (gdb_demangle): Use gdb_sigmask. * gdbsupport/common.m4 (GDB_AC_COMMON): Check for pthread_sigmask. * configure, config.in: Rebuild. * gdbsupport/block-signals.h: New file. gdb/gdbserver/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * remote-utils.c (block_unblock_async_io): Use gdb_sigmask. * linux-low.c (linux_wait_for_event_filtered, linux_async): Use gdb_sigmask. * configure, config.in: Rebuild. Change-Id: If3f37dc57dd859c226e9e4d79458a0514746e8c6
2019-09-29 16:50:15 +02:00
gdb_sigmask (SIG_SETMASK, &prev_mask, NULL);
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
return 0;
* inferiors.c (change_inferior_id): Delete. (add_pid_to_list, pull_pid_from_list): New. * linux-low.c (PTRACE_SETOPTIONS, PTRACE_GETEVENTMSG) (PTRACE_O_TRACESYSGOOD, PTRACE_O_TRACEFORK, PTRACE_O_TRACEVFORK) (PTRACE_O_TRACECLONE, PTRACE_O_TRACEEXEC, PTRACE_O_TRACEVFORKDONE) (PTRACE_O_TRACEEXIT, PTRACE_EVENT_FORK, PTRACE_EVENT_VFORK) (PTRACE_EVENT_CLONE, PTRACE_EVENT_EXEC, PTRACE_EVENT_VFORK_DONE) (PTRACE_EVENT_EXIT, __WALL): Provide default definitions. (stopped_pids, thread_db_active, must_set_ptrace_flags): New variables. (using_threads): Always set to 1. (handle_extended_wait): New. (add_process): Do not set TID. (linux_create_inferior): Set must_set_ptrace_flags. (linux_attach_lwp): Remove TID argument. Do not check using_threads. Use PTRACE_SETOPTIONS. Call new_thread_notify. Update all callers. (linux_thread_alive): Rename TID argument to LWPID. (linux_wait_for_process): Handle unknown processes. Do not use TID. (linux_wait_for_event): Do not use TID or check using_threads. Update call to dead_thread_notify. Call handle_extended_wait. (linux_create_inferior): Use PTRACE_SETOPTIONS. (send_sigstop): Delete sigstop_sent. (wait_for_sigstop): Avoid TID. (linux_supports_tracefork_flag, linux_tracefork_child, my_waitpid) (linux_test_for_tracefork): New. (linux_lookup_signals): Use thread_db_active and linux_supports_tracefork_flag. (initialize_low): Use thread_db_active and linux_test_for_tracefork. * linux-low.h (get_process_thread): Avoid TID. (struct process_ifo): Move thread_known and tid to the end. Remove sigstop_sent. (linux_attach_lwp, thread_db_init): Update prototypes. * server.h (change_inferior_id): Delete prototype. (add_pid_to_list, pull_pid_from_list): New prototypes. * thread-db.c (thread_db_use_events): New. (find_first_thread): Rename to... (find_one_thread): ...this. Update callers and messages. Do not call fatal. Check thread_db_use_events. Do not call change_inferior_id or new_thread_notify. (maybe_attach_thread): Update. Do not call new_thread_notify. (thread_db_init): Set thread_db_use_events. Check use_events. * utils.c (fatal, warning): Correct message prefix.
2007-10-23 22:05:03 +02:00
}
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
/* Block until we get an event reported with SIGCHLD. */
if (debug_threads)
debug_printf ("sigsuspend'ing\n");
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
sigsuspend (&prev_mask);
Add RAII class for blocking gdb signals This adds configury support and an RAII class that can be used to temporarily block signals that are used by gdb. (This class is not used in this patch, but it split out for easier review.) The idea of this patch is that these signals should only be delivered to the main thread. So, when creating a background thread, they are temporarily blocked; the blocked state is inherited by the new thread. The sigprocmask man page says: The use of sigprocmask() is unspecified in a multithreaded process; see pthread_sigmask(3). This patch changes gdb to use pthread_sigmask when appropriate, by introducing a convenience define. I've updated gdbserver as well, because I had to touch gdbsupport, and because the threading patches will make it link against the thread library. I chose not to touch the NTO code, because I don't know anything about that platform and because I cannot test it. Finally, this modifies an existing spot in the Guile layer to use the new facility. gdb/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * gdbsupport/signals-state-save-restore.c (original_signal_mask): Remove comment. (save_original_signals_state, restore_original_signals_state): Use gdb_sigmask. * linux-nat.c (block_child_signals, restore_child_signals_mask) (_initialize_linux_nat): Use gdb_sigmask. * guile/guile.c (_initialize_guile): Use block_signals. * Makefile.in (HFILES_NO_SRCDIR): Add gdb-sigmask.h. * gdbsupport/gdb-sigmask.h: New file. * event-top.c (async_sigtstp_handler): Use gdb_sigmask. * cp-support.c (gdb_demangle): Use gdb_sigmask. * gdbsupport/common.m4 (GDB_AC_COMMON): Check for pthread_sigmask. * configure, config.in: Rebuild. * gdbsupport/block-signals.h: New file. gdb/gdbserver/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * remote-utils.c (block_unblock_async_io): Use gdb_sigmask. * linux-low.c (linux_wait_for_event_filtered, linux_async): Use gdb_sigmask. * configure, config.in: Rebuild. Change-Id: If3f37dc57dd859c226e9e4d79458a0514746e8c6
2019-09-29 16:50:15 +02:00
gdb_sigmask (SIG_SETMASK, &prev_mask, NULL);
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
goto retry;
}
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
Add RAII class for blocking gdb signals This adds configury support and an RAII class that can be used to temporarily block signals that are used by gdb. (This class is not used in this patch, but it split out for easier review.) The idea of this patch is that these signals should only be delivered to the main thread. So, when creating a background thread, they are temporarily blocked; the blocked state is inherited by the new thread. The sigprocmask man page says: The use of sigprocmask() is unspecified in a multithreaded process; see pthread_sigmask(3). This patch changes gdb to use pthread_sigmask when appropriate, by introducing a convenience define. I've updated gdbserver as well, because I had to touch gdbsupport, and because the threading patches will make it link against the thread library. I chose not to touch the NTO code, because I don't know anything about that platform and because I cannot test it. Finally, this modifies an existing spot in the Guile layer to use the new facility. gdb/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * gdbsupport/signals-state-save-restore.c (original_signal_mask): Remove comment. (save_original_signals_state, restore_original_signals_state): Use gdb_sigmask. * linux-nat.c (block_child_signals, restore_child_signals_mask) (_initialize_linux_nat): Use gdb_sigmask. * guile/guile.c (_initialize_guile): Use block_signals. * Makefile.in (HFILES_NO_SRCDIR): Add gdb-sigmask.h. * gdbsupport/gdb-sigmask.h: New file. * event-top.c (async_sigtstp_handler): Use gdb_sigmask. * cp-support.c (gdb_demangle): Use gdb_sigmask. * gdbsupport/common.m4 (GDB_AC_COMMON): Check for pthread_sigmask. * configure, config.in: Rebuild. * gdbsupport/block-signals.h: New file. gdb/gdbserver/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * remote-utils.c (block_unblock_async_io): Use gdb_sigmask. * linux-low.c (linux_wait_for_event_filtered, linux_async): Use gdb_sigmask. * configure, config.in: Rebuild. Change-Id: If3f37dc57dd859c226e9e4d79458a0514746e8c6
2019-09-29 16:50:15 +02:00
gdb_sigmask (SIG_SETMASK, &prev_mask, NULL);
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
current_thread = event_thread;
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
return lwpid_of (event_thread);
}
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
int
linux_process_target::wait_for_event (ptid_t ptid, int *wstatp, int options)
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
{
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
return wait_for_event_filtered (ptid, ptid, wstatp, options);
}
/* Select one LWP out of those that have events pending. */
static void
select_event_lwp (struct lwp_info **orig_lp)
{
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
struct thread_info *event_thread = NULL;
/* In all-stop, give preference to the LWP that is being
single-stepped. There will be at most one, and it's the LWP that
the core is most interested in. If we didn't do this, then we'd
have to handle pending step SIGTRAPs somehow in case the core
later continues the previously-stepped thread, otherwise we'd
report the pending SIGTRAP, and the core, not having stepped the
thread, wouldn't understand what the trap was for, and therefore
would report it to the user as a random signal. */
if (!non_stop)
{
event_thread = find_thread ([] (thread_info *thread)
{
lwp_info *lp = get_thread_lwp (thread);
return (thread->last_status.kind == TARGET_WAITKIND_IGNORE
&& thread->last_resume_kind == resume_step
&& lp->status_pending_p);
});
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
if (event_thread != NULL)
{
if (debug_threads)
debug_printf ("SEL: Select single-step %s\n",
target_pid_to_str (ptid_of (event_thread)));
}
}
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
if (event_thread == NULL)
{
/* No single-stepping LWP. Select one at random, out of those
which have had events. */
event_thread = find_thread_in_random ([&] (thread_info *thread)
{
lwp_info *lp = get_thread_lwp (thread);
/* Only resumed LWPs that have an event pending. */
return (thread->last_status.kind == TARGET_WAITKIND_IGNORE
&& lp->status_pending_p);
});
}
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
if (event_thread != NULL)
{
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
struct lwp_info *event_lp = get_thread_lwp (event_thread);
/* Switch the event LWP. */
*orig_lp = event_lp;
}
}
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
/* Decrement the suspend count of all LWPs, except EXCEPT, if non
NULL. */
static void
unsuspend_all_lwps (struct lwp_info *except)
{
for_each_thread ([&] (thread_info *thread)
{
lwp_info *lwp = get_thread_lwp (thread);
if (lwp != except)
lwp_suspended_decr (lwp);
});
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
}
static bool lwp_running (thread_info *thread);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
/* Stabilize threads (move out of jump pads).
If a thread is midway collecting a fast tracepoint, we need to
finish the collection and move it out of the jump pad before
reporting the signal.
This avoids recursion while collecting (when a signal arrives
midway, and the signal handler itself collects), which would trash
the trace buffer. In case the user set a breakpoint in a signal
handler, this avoids the backtrace showing the jump pad, etc..
Most importantly, there are certain things we can't do safely if
threads are stopped in a jump pad (or in its callee's). For
example:
- starting a new trace run. A thread still collecting the
previous run, could trash the trace buffer when resumed. The trace
buffer control structures would have been reset but the thread had
no way to tell. The thread could even midway memcpy'ing to the
buffer, which would mean that when resumed, it would clobber the
trace buffer that had been set for a new run.
- we can't rewrite/reuse the jump pads for new tracepoints
safely. Say you do tstart while a thread is stopped midway while
collecting. When the thread is later resumed, it finishes the
collection, and returns to the jump pad, to execute the original
instruction that was under the tracepoint jump at the time the
older run had been started. If the jump pad had been rewritten
since for something else in the new run, the thread would now
execute the wrong / random instructions. */
void
linux_process_target::stabilize_threads ()
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
{
gdbserver/linux-low: turn 'get_thread_area' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_thread_area' linux target op into a method of process_stratum_target. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <stuck_in_jump_pad> <linux_fast_tracepoint_collecting> <low_get_thread_area>: Declare. * linux-low.cc (supports_fast_tracepoints): Remove. (linux_fast_tracepoint_collecting): Turn into... (linux_process_target::linux_fast_tracepoint_collecting): ...this. (linux_process_target::low_get_thread_area): Define. (stuck_in_jump_pad_callback): Turn into... (linux_process_target::stuck_in_jump_pad): ...this. Update the caller below. (linux_process_target::stabilize_threads) * linux-x86-low.cc (class x86_target) <low_get_thread_area>: Declare. (x86_get_thread_area): Turn into... (x86_target::low_get_thread_area): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <low_get_thread_area>: Declare. (aarch64_get_thread_area): Turn into... (aarch64_target::low_get_thread_area): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (class ppc_target) <low_get_thread_area>: Declare. (ppc_get_thread_area): Turn into... (ppc_target::low_get_thread_area): ...this. (the_low_target): Remove the op field. * linux-s390-low.cc (class s390_target) <low_get_thread_area>: Declare. (s390_get_thread_area): Turn into... (s390_target::low_get_thread_area): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (the_low_target): Remove the op field. * linux-bfin-low.cc (the_low_target): Ditto. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:30 +02:00
thread_info *thread_stuck = find_thread ([this] (thread_info *thread)
{
return stuck_in_jump_pad (thread);
});
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
if (thread_stuck != NULL)
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("can't stabilize, LWP %ld is stuck in jump pad\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
lwpid_of (thread_stuck));
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
return;
}
thread_info *saved_thread = current_thread;
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
stabilizing_threads = 1;
/* Kick 'em all. */
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
for_each_thread ([this] (thread_info *thread)
{
move_out_of_jump_pad (thread);
});
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
/* Loop until all are stopped out of the jump pads. */
while (find_thread (lwp_running) != NULL)
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
{
struct target_waitstatus ourstatus;
struct lwp_info *lwp;
int wstat;
/* Note that we go through the full wait even loop. While
moving threads out of jump pad, we need to be able to step
over internal breakpoints and such. */
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
wait_1 (minus_one_ptid, &ourstatus, 0);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
if (ourstatus.kind == TARGET_WAITKIND_STOPPED)
{
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
lwp = get_thread_lwp (current_thread);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
/* Lock it. */
gdbserver: Fix non-stop / fork / step-over issues Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html This adds a test that has a multithreaded program have several threads continuously fork, while another thread continuously steps over a breakpoint. This exposes several intertwined issues, which this patch addresses: - When we're stopping and suspending threads, some thread may fork, and we missed setting its suspend count to 1, like we do when a new clone/thread is detected. When we next unsuspend threads, the fork child's suspend count goes below 0, which is bogus and fails an assertion. - If a step-over is cancelled because a signal arrives, but then gdb is not interested in the signal, we pass the signal straight back to the inferior. However, we miss that we need to re-increment the suspend counts of all other threads that had been paused for the step-over. As a result, other threads indefinitely end up stuck stopped. - If a detach request comes in just while gdbserver is handling a step-over (in the test at hand, this is GDB detaching the fork child), gdbserver internal errors in stabilize_thread's helpers, which assert that all thread's suspend counts are 0 (otherwise we wouldn't be able to move threads out of the jump pads). The suspend counts aren't 0 while a step-over is in progress, because all threads but the one stepping past the breakpoint must remain paused until the step-over finishes and the breakpoint can be reinserted. - Occasionally, we see "BAD - reinserting but not stepping." being output (from within linux_resume_one_lwp_throw). That was because GDB pokes memory while gdbserver is busy with a step-over, and that suspends threads, and then re-resumes them with proceed_one_lwp, which missed another reason to tell linux_resume_one_lwp that the thread should be set back to stepping. - In a couple places, we were resuming threads that are meant to be suspended. E.g., when a vCont;c/s request for thread B comes in just while gdbserver is stepping thread A past a breakpoint. The resume for thread B must be deferred until the step-over finishes. - The test runs with both "set detach-on-fork" on and off. When off, it exercises the case of GDB detaching the fork child explicitly. When on, it exercises the case of gdb resuming the child explicitly. In the "off" case, gdb seems to exponentially become slower as new inferiors are created. This is _very_ noticeable as with only 100 inferiors gdb is crawling already, which makes the test take quite a bit to run. For that reason, I've disabled the "off" variant for now. gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * target/waitstatus.h (enum target_stop_reason) <TARGET_STOPPED_BY_SINGLE_STEP>: New value. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the fork child's suspend count if stopping and suspending threads. (check_stopped_by_breakpoint): If stopped by trace, set the LWP's stop reason to TARGET_STOPPED_BY_SINGLE_STEP. (linux_detach): Complete an ongoing step-over. (lwp_suspended_inc, lwp_suspended_decr): New functions. Use throughout. (resume_stopped_resumed_lwps): Don't resume a suspended thread. (linux_wait_1): If passing a signal to the inferior after finishing a step-over, unsuspend and re-resume all lwps. If we see a single-step event but the thread should be continuing, don't pass the trap to gdb. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use internal_error instead of gdb_assert. (enqueue_pending_signal): New function. (check_ptrace_stopped_lwp_gone): Add debug output. (start_step_over): Use internal_error instead of gdb_assert. (complete_ongoing_step_over): New function. (linux_resume_one_thread): Don't resume a suspended thread. (proceed_one_lwp): If the LWP is stepping over a breakpoint, reset it stepping. gdb/testsuite/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * gdb.threads/forking-threads-plus-breakpoint.exp: New file. * gdb.threads/forking-threads-plus-breakpoint.c: New file.
2015-08-06 11:30:18 +02:00
lwp_suspended_inc (lwp);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. gdb/gdbserver/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. include/gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 * gdb/signals.def: Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/arm/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/avr/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/common/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/cr16/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/d10v/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/erc32/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/m32c/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/ppc/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rl78/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rx/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout.
2012-05-24 18:51:47 +02:00
if (ourstatus.value.sig != GDB_SIGNAL_0
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
|| current_thread->last_resume_kind == resume_stop)
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
{
wstat = W_STOPCODE (gdb_signal_to_host (ourstatus.value.sig));
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
enqueue_one_deferred_signal (lwp, &wstat);
}
}
}
unsuspend_all_lwps (NULL);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
stabilizing_threads = 0;
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
current_thread = saved_thread;
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
if (debug_threads)
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
{
gdbserver/linux-low: turn 'get_thread_area' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_thread_area' linux target op into a method of process_stratum_target. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <stuck_in_jump_pad> <linux_fast_tracepoint_collecting> <low_get_thread_area>: Declare. * linux-low.cc (supports_fast_tracepoints): Remove. (linux_fast_tracepoint_collecting): Turn into... (linux_process_target::linux_fast_tracepoint_collecting): ...this. (linux_process_target::low_get_thread_area): Define. (stuck_in_jump_pad_callback): Turn into... (linux_process_target::stuck_in_jump_pad): ...this. Update the caller below. (linux_process_target::stabilize_threads) * linux-x86-low.cc (class x86_target) <low_get_thread_area>: Declare. (x86_get_thread_area): Turn into... (x86_target::low_get_thread_area): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <low_get_thread_area>: Declare. (aarch64_get_thread_area): Turn into... (aarch64_target::low_get_thread_area): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (class ppc_target) <low_get_thread_area>: Declare. (ppc_get_thread_area): Turn into... (ppc_target::low_get_thread_area): ...this. (the_low_target): Remove the op field. * linux-s390-low.cc (class s390_target) <low_get_thread_area>: Declare. (s390_get_thread_area): Turn into... (s390_target::low_get_thread_area): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (the_low_target): Remove the op field. * linux-bfin-low.cc (the_low_target): Ditto. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:30 +02:00
thread_stuck = find_thread ([this] (thread_info *thread)
{
return stuck_in_jump_pad (thread);
});
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
if (thread_stuck != NULL)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("couldn't stabilize, LWP %ld got stuck in jump pad\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
lwpid_of (thread_stuck));
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
}
}
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
/* Convenience function that is called when the kernel reports an
event that is not passed out to GDB. */
static ptid_t
ignore_event (struct target_waitstatus *ourstatus)
{
/* If we got an event, there may still be others, as a single
SIGCHLD can indicate more than one child stopped. This forces
another target_wait call. */
async_file_mark ();
ourstatus->kind = TARGET_WAITKIND_IGNORE;
return null_ptid;
}
gdbserver/linux-low: turn process/thread addition/deletion ops into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'new_process', 'delete_process', 'new_thread', 'delete_thread', and 'new_fork' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <add_linux_process> <add_lwp> <delete_lwp> <attach_lwp> <detach_one_lwp> <check_zombie_leaders> <filter_exit_event> <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. * linux-low.cc (delete_lwp): Turn into... (linux_process_target::delete_lwp): ...this. (linux_process_target::low_delete_thread): Define. (linux_add_process): Turn into... (linux_process_target::add_linux_process): ...this. (linux_process_target::low_new_process): Define. (linux_process_target::low_delete_process): Define. (linux_process_target::low_new_fork): Define. (add_lwp): Turn into... (linux_process_target::add_lwp): ...this. (linux_process_target::low_new_thread): Define. (linux_attach_lwp): Turn into... (linux_process_target::attach_lwp): ...this. (linux_detach_one_lwp): Turn into... (linux_process_target::detach_one_lwp): ...this. (linux_detach_lwp_callback): Remove and inline... (linux_process_target::detach): ...here. (check_zombie_leaders): Turn into... (linux_process_target::check_zombie_leaders): ...this. (filter_exit_event): Turn into... (linux_process_target::filter_exit_event): ...this. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::create_inferior) (attach_proc_task_lwp_callback) (linux_process_target::attach) (linux_process_target::detach) (linux_process_target::mourn) * thread-db.cc (attach_thread) * linux-x86-low.cc (class x86_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (x86_linux_new_process): Turn into... (x86_target::low_new_process): ...this. (x86_linux_delete_process): Turn into... (x86_target::low_delete_process): ...this. (x86_target::low_new_thread): Define. (x86_target::low_delete_thread): Define. (x86_linux_new_fork): Turn into... (x86_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (aarch64_linux_new_process): Turn into... (aarch64_target::low_new_process): ...this. (aarch64_linux_delete_process): Turn into... (aarch64_target::low_delete_process): ...this. (aarch64_target::low_new_thread): Define. (aarch64_target::low_delete_thread): Define. (aarch64_linux_new_fork): Turn into... (aarch64_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (arm_new_process): Turn into... (arm_target::low_new_process): ...this. (arm_delete_process): Turn into... (arm_target::low_delete_process): ...this. (arm_new_thread): Turn into... (arm_target::low_new_thread): ...this. (arm_delete_thread): Turn into... (arm_target::low_delete_thread): ...this. (arm_new_fork): Turn into... (arm_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_new_process> <low_delete_process> <low_new_thread> <low_delete_thread> <low_new_fork>: Declare. (mips_linux_new_process): Turn into... (mips_target::low_new_process): ...this. (mips_linux_delete_process): Turn into... (mips_target::low_delete_process): ...this. (mips_linux_new_thread): Turn into... (mips_target::low_new_thread): ...this. (mips_linux_delete_thread): Turn into... (mips_target::low_delete_thread): ...this. (mips_linux_new_fork): Turn into... (mips_target::low_new_fork): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:28 +02:00
ptid_t
linux_process_target::filter_exit_event (lwp_info *event_child,
target_waitstatus *ourstatus)
Remote thread create/exit events When testing with "maint set target-non-stop on", a few threading-related tests expose an issue that requires new RSP packets. Say there are 3 threads running, 1-3. If GDB tries to stop thread 1, 2 and 3, and then waits for their stops, but meanwhile say, thread 2 exits, GDB hangs forever waiting for a stop for thread 2 that won't ever happen. This patch fixes the issue by adding support for thread exit events to the protocol. However, we don't want these always enabled, as they're useless most of the time, and would slow down remote debugging. So I made it so that GDB can enable/disable them, and then made gdb do that around the cases that need it, which currently is only infrun.c:stop_all_threads. In turn, if we have thread exit events, then the extra "thread x exited" traffic slows down attach-many-short-lived-threads.exp enough that gdb has trouble keeping up with new threads that are spawned while gdb tries to stop existing ones. To fix that I added support for the counterpart thread created events too. Enabling those when we try to stop threads ensures that new threads never get a chance to themselves start new threads, killing the race. gdb/doc/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): List "set/show remote thread-events" command in configuration table. (Stop Reply Packets): Document "T05 create" stop reason and 'w' stop reply. (General Query Packets): Document QThreadEvents packet. Document QThreadEvents qSupported feature. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. If GDB wants to hear about thread create events, leave the new child's status pending. (linux_low_filter_event): If GDB wants to hear about thread exit events, leave the LWP marked dead and don't delete it. (linux_wait_for_event_filtered): Don't check for thread exit. (filter_exit_event): New function. (linux_wait_1): Use it, when returning an exit event. (linux_resume_one_lwp_throw): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. * remote-utils.c (prepare_resume_reply): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.c (report_thread_events): New global. (handle_general_set): Handle QThreadEvents. (handle_query) <qSupported>: Handle and report QThreadEvents+; (handle_target_event): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.h (report_thread_events): Declare. gdb/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * NEWS (New commands): Mention "set/show remote thread-events" commands. (New remote packets): Mention thread created/exited stop reasons and QThreadEvents packet. * infrun.c (disable_thread_events): New function. (stop_all_threads): Disable/enable thread create/exit events. Handle TARGET_WAITKIND_THREAD_EXITED. (handle_inferior_event_1): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * remote.c (remove_child_of_pending_fork): Also remove threads of threads that have TARGET_WAITKIND_THREAD_EXITED events. (remote_parse_stop_reply): Handle "create" magic register. Handle 'w' stop reply. (initialize_remote): Install remote_thread_events as to_thread_events target hook. (remote_thread_events): New function. * target-delegates.c: Regenerate. * target.c (target_thread_events): New function. * target.h (struct target_ops) <to_thread_events>: New field. (target_thread_events): Declare. * target/waitstatus.c (target_waitstatus_to_string): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * target/waitstatus.h (enum target_waitkind) <TARGET_WAITKIND_THREAD_CREATED, TARGET_WAITKIND_THREAD_EXITED): New values.
2015-11-30 17:05:21 +01:00
{
client_state &cs = get_client_state ();
Remote thread create/exit events When testing with "maint set target-non-stop on", a few threading-related tests expose an issue that requires new RSP packets. Say there are 3 threads running, 1-3. If GDB tries to stop thread 1, 2 and 3, and then waits for their stops, but meanwhile say, thread 2 exits, GDB hangs forever waiting for a stop for thread 2 that won't ever happen. This patch fixes the issue by adding support for thread exit events to the protocol. However, we don't want these always enabled, as they're useless most of the time, and would slow down remote debugging. So I made it so that GDB can enable/disable them, and then made gdb do that around the cases that need it, which currently is only infrun.c:stop_all_threads. In turn, if we have thread exit events, then the extra "thread x exited" traffic slows down attach-many-short-lived-threads.exp enough that gdb has trouble keeping up with new threads that are spawned while gdb tries to stop existing ones. To fix that I added support for the counterpart thread created events too. Enabling those when we try to stop threads ensures that new threads never get a chance to themselves start new threads, killing the race. gdb/doc/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): List "set/show remote thread-events" command in configuration table. (Stop Reply Packets): Document "T05 create" stop reason and 'w' stop reply. (General Query Packets): Document QThreadEvents packet. Document QThreadEvents qSupported feature. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. If GDB wants to hear about thread create events, leave the new child's status pending. (linux_low_filter_event): If GDB wants to hear about thread exit events, leave the LWP marked dead and don't delete it. (linux_wait_for_event_filtered): Don't check for thread exit. (filter_exit_event): New function. (linux_wait_1): Use it, when returning an exit event. (linux_resume_one_lwp_throw): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. * remote-utils.c (prepare_resume_reply): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.c (report_thread_events): New global. (handle_general_set): Handle QThreadEvents. (handle_query) <qSupported>: Handle and report QThreadEvents+; (handle_target_event): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.h (report_thread_events): Declare. gdb/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * NEWS (New commands): Mention "set/show remote thread-events" commands. (New remote packets): Mention thread created/exited stop reasons and QThreadEvents packet. * infrun.c (disable_thread_events): New function. (stop_all_threads): Disable/enable thread create/exit events. Handle TARGET_WAITKIND_THREAD_EXITED. (handle_inferior_event_1): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * remote.c (remove_child_of_pending_fork): Also remove threads of threads that have TARGET_WAITKIND_THREAD_EXITED events. (remote_parse_stop_reply): Handle "create" magic register. Handle 'w' stop reply. (initialize_remote): Install remote_thread_events as to_thread_events target hook. (remote_thread_events): New function. * target-delegates.c: Regenerate. * target.c (target_thread_events): New function. * target.h (struct target_ops) <to_thread_events>: New field. (target_thread_events): Declare. * target/waitstatus.c (target_waitstatus_to_string): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * target/waitstatus.h (enum target_waitkind) <TARGET_WAITKIND_THREAD_CREATED, TARGET_WAITKIND_THREAD_EXITED): New values.
2015-11-30 17:05:21 +01:00
struct thread_info *thread = get_lwp_thread (event_child);
ptid_t ptid = ptid_of (thread);
if (!last_thread_of_process_p (pid_of (thread)))
{
if (cs.report_thread_events)
Remote thread create/exit events When testing with "maint set target-non-stop on", a few threading-related tests expose an issue that requires new RSP packets. Say there are 3 threads running, 1-3. If GDB tries to stop thread 1, 2 and 3, and then waits for their stops, but meanwhile say, thread 2 exits, GDB hangs forever waiting for a stop for thread 2 that won't ever happen. This patch fixes the issue by adding support for thread exit events to the protocol. However, we don't want these always enabled, as they're useless most of the time, and would slow down remote debugging. So I made it so that GDB can enable/disable them, and then made gdb do that around the cases that need it, which currently is only infrun.c:stop_all_threads. In turn, if we have thread exit events, then the extra "thread x exited" traffic slows down attach-many-short-lived-threads.exp enough that gdb has trouble keeping up with new threads that are spawned while gdb tries to stop existing ones. To fix that I added support for the counterpart thread created events too. Enabling those when we try to stop threads ensures that new threads never get a chance to themselves start new threads, killing the race. gdb/doc/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): List "set/show remote thread-events" command in configuration table. (Stop Reply Packets): Document "T05 create" stop reason and 'w' stop reply. (General Query Packets): Document QThreadEvents packet. Document QThreadEvents qSupported feature. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. If GDB wants to hear about thread create events, leave the new child's status pending. (linux_low_filter_event): If GDB wants to hear about thread exit events, leave the LWP marked dead and don't delete it. (linux_wait_for_event_filtered): Don't check for thread exit. (filter_exit_event): New function. (linux_wait_1): Use it, when returning an exit event. (linux_resume_one_lwp_throw): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. * remote-utils.c (prepare_resume_reply): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.c (report_thread_events): New global. (handle_general_set): Handle QThreadEvents. (handle_query) <qSupported>: Handle and report QThreadEvents+; (handle_target_event): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.h (report_thread_events): Declare. gdb/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * NEWS (New commands): Mention "set/show remote thread-events" commands. (New remote packets): Mention thread created/exited stop reasons and QThreadEvents packet. * infrun.c (disable_thread_events): New function. (stop_all_threads): Disable/enable thread create/exit events. Handle TARGET_WAITKIND_THREAD_EXITED. (handle_inferior_event_1): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * remote.c (remove_child_of_pending_fork): Also remove threads of threads that have TARGET_WAITKIND_THREAD_EXITED events. (remote_parse_stop_reply): Handle "create" magic register. Handle 'w' stop reply. (initialize_remote): Install remote_thread_events as to_thread_events target hook. (remote_thread_events): New function. * target-delegates.c: Regenerate. * target.c (target_thread_events): New function. * target.h (struct target_ops) <to_thread_events>: New field. (target_thread_events): Declare. * target/waitstatus.c (target_waitstatus_to_string): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * target/waitstatus.h (enum target_waitkind) <TARGET_WAITKIND_THREAD_CREATED, TARGET_WAITKIND_THREAD_EXITED): New values.
2015-11-30 17:05:21 +01:00
ourstatus->kind = TARGET_WAITKIND_THREAD_EXITED;
else
ourstatus->kind = TARGET_WAITKIND_IGNORE;
delete_lwp (event_child);
}
return ptid;
}
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
/* Returns 1 if GDB is interested in any event_child syscalls. */
static int
gdb_catching_syscalls_p (struct lwp_info *event_child)
{
struct thread_info *thread = get_lwp_thread (event_child);
struct process_info *proc = get_thread_process (thread);
return !proc->syscalls_to_catch.empty ();
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
}
gdbserver/linux-low: turn 'get_syscall_trapinfo' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_syscall_trapinfo' linux target op into a method of process_stratum_target. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <get_syscall_trapinfo> <gdb_catch_this_syscall> <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. * linux-low.cc (get_syscall_trapinfo): Turn into... (linux_process_target::get_syscall_trapinfo): ...this. (linux_process_target::low_get_syscall_trapinfo): Define. (gdb_catch_this_syscall_p): Turn into... (linux_process_target::gdb_catch_this_syscall): ...this. (linux_process_target::low_supports_catch_syscall): Define. Update the callers below. (linux_process_target::wait_1) (linux_process_target::supports_catch_syscall) * linux-x86-low.cc (class x86_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (x86_target::low_supports_catch_syscall): Define. (x86_get_syscall_trapinfo): Turn into... (x86_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (aarch64_target::low_supports_catch_syscall): Define. (aarch64_get_syscall_trapinfo): Turn into... (aarch64_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (class arm_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (arm_target::low_supports_catch_syscall): Define. (arm_get_syscall_trapinfo): Turn into... (arm_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (the_low_target): Remove the op field. * linux-s390-low.cc (the_low_target): Remove the op field.
2020-04-02 15:11:31 +02:00
bool
linux_process_target::gdb_catch_this_syscall (lwp_info *event_child)
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
{
int sysno;
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
struct thread_info *thread = get_lwp_thread (event_child);
struct process_info *proc = get_thread_process (thread);
if (proc->syscalls_to_catch.empty ())
gdbserver/linux-low: turn 'get_syscall_trapinfo' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_syscall_trapinfo' linux target op into a method of process_stratum_target. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <get_syscall_trapinfo> <gdb_catch_this_syscall> <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. * linux-low.cc (get_syscall_trapinfo): Turn into... (linux_process_target::get_syscall_trapinfo): ...this. (linux_process_target::low_get_syscall_trapinfo): Define. (gdb_catch_this_syscall_p): Turn into... (linux_process_target::gdb_catch_this_syscall): ...this. (linux_process_target::low_supports_catch_syscall): Define. Update the callers below. (linux_process_target::wait_1) (linux_process_target::supports_catch_syscall) * linux-x86-low.cc (class x86_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (x86_target::low_supports_catch_syscall): Define. (x86_get_syscall_trapinfo): Turn into... (x86_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (aarch64_target::low_supports_catch_syscall): Define. (aarch64_get_syscall_trapinfo): Turn into... (aarch64_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (class arm_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (arm_target::low_supports_catch_syscall): Define. (arm_get_syscall_trapinfo): Turn into... (arm_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (the_low_target): Remove the op field. * linux-s390-low.cc (the_low_target): Remove the op field.
2020-04-02 15:11:31 +02:00
return false;
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
if (proc->syscalls_to_catch[0] == ANY_SYSCALL)
gdbserver/linux-low: turn 'get_syscall_trapinfo' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_syscall_trapinfo' linux target op into a method of process_stratum_target. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <get_syscall_trapinfo> <gdb_catch_this_syscall> <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. * linux-low.cc (get_syscall_trapinfo): Turn into... (linux_process_target::get_syscall_trapinfo): ...this. (linux_process_target::low_get_syscall_trapinfo): Define. (gdb_catch_this_syscall_p): Turn into... (linux_process_target::gdb_catch_this_syscall): ...this. (linux_process_target::low_supports_catch_syscall): Define. Update the callers below. (linux_process_target::wait_1) (linux_process_target::supports_catch_syscall) * linux-x86-low.cc (class x86_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (x86_target::low_supports_catch_syscall): Define. (x86_get_syscall_trapinfo): Turn into... (x86_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (aarch64_target::low_supports_catch_syscall): Define. (aarch64_get_syscall_trapinfo): Turn into... (aarch64_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (class arm_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (arm_target::low_supports_catch_syscall): Define. (arm_get_syscall_trapinfo): Turn into... (arm_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (the_low_target): Remove the op field. * linux-s390-low.cc (the_low_target): Remove the op field.
2020-04-02 15:11:31 +02:00
return true;
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
get_syscall_trapinfo (event_child, &sysno);
for (int iter : proc->syscalls_to_catch)
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
if (iter == sysno)
gdbserver/linux-low: turn 'get_syscall_trapinfo' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_syscall_trapinfo' linux target op into a method of process_stratum_target. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <get_syscall_trapinfo> <gdb_catch_this_syscall> <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. * linux-low.cc (get_syscall_trapinfo): Turn into... (linux_process_target::get_syscall_trapinfo): ...this. (linux_process_target::low_get_syscall_trapinfo): Define. (gdb_catch_this_syscall_p): Turn into... (linux_process_target::gdb_catch_this_syscall): ...this. (linux_process_target::low_supports_catch_syscall): Define. Update the callers below. (linux_process_target::wait_1) (linux_process_target::supports_catch_syscall) * linux-x86-low.cc (class x86_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (x86_target::low_supports_catch_syscall): Define. (x86_get_syscall_trapinfo): Turn into... (x86_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (aarch64_target::low_supports_catch_syscall): Define. (aarch64_get_syscall_trapinfo): Turn into... (aarch64_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (class arm_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (arm_target::low_supports_catch_syscall): Define. (arm_get_syscall_trapinfo): Turn into... (arm_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (the_low_target): Remove the op field. * linux-s390-low.cc (the_low_target): Remove the op field.
2020-04-02 15:11:31 +02:00
return true;
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
gdbserver/linux-low: turn 'get_syscall_trapinfo' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_syscall_trapinfo' linux target op into a method of process_stratum_target. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <get_syscall_trapinfo> <gdb_catch_this_syscall> <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. * linux-low.cc (get_syscall_trapinfo): Turn into... (linux_process_target::get_syscall_trapinfo): ...this. (linux_process_target::low_get_syscall_trapinfo): Define. (gdb_catch_this_syscall_p): Turn into... (linux_process_target::gdb_catch_this_syscall): ...this. (linux_process_target::low_supports_catch_syscall): Define. Update the callers below. (linux_process_target::wait_1) (linux_process_target::supports_catch_syscall) * linux-x86-low.cc (class x86_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (x86_target::low_supports_catch_syscall): Define. (x86_get_syscall_trapinfo): Turn into... (x86_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (aarch64_target::low_supports_catch_syscall): Define. (aarch64_get_syscall_trapinfo): Turn into... (aarch64_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (class arm_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (arm_target::low_supports_catch_syscall): Define. (arm_get_syscall_trapinfo): Turn into... (arm_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (the_low_target): Remove the op field. * linux-s390-low.cc (the_low_target): Remove the op field.
2020-04-02 15:11:31 +02:00
return false;
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
}
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
ptid_t
linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
int target_options)
{
client_state &cs = get_client_state ();
int w;
struct lwp_info *event_child;
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
int options;
int pid;
int step_over_finished;
int bp_explains_trap;
int maybe_internal_trap;
int report_to_gdb;
gdb/gdbserver/ * server.h (LONGEST): New. (struct thread_info) <while_stepping>: New field. (unpack_varlen_hex, xrealloc, pulongest, plongest, phex_nz): Declare. (initialize_tracepoint, handle_tracepoint_general_set) (handle_tracepoint_query, tracepoint_finished_step) (tracepoint_was_hit, release_while_stepping_state_list): (current_traceframe): Declare. * server.c (handle_general_set): Handle tracepoint packets. (read_memory): New. (write_memory): New. (handle_search_memory_1): Use read_memory. (handle_query): Report support for conditional tracepoints, trace state variables, and tracepoint sources. Handle tracepoint queries. (main): Initialize the tracepoints module. (process_serial_event): Handle traceframe reads/writes. * linux-low.c (handle_tracepoints): New. (linux_wait_1): Call it. (linux_resume_one_lwp): Handle while-stepping. (linux_supports_tracepoints, linux_read_pc, linux_write_pc): New. (linux_target_ops): Install them. * linux-low.h (struct linux_target_ops) <supports_tracepoints>: New field. * linux-x86-low.c (x86_supports_tracepoints): New. (the_low_target). Install it. * mem-break.h (delete_breakpoint): Declare. * mem-break.c (delete_breakpoint): Make external. * target.h (struct target_ops): Add `supports_tracepoints', `read_pc', and `write_pc' fields. (target_supports_tracepoints): Define. * utils.c (xrealloc, decimal2str, pulongest, plongest, thirty_two) (phex_nz): New. * regcache.h (struct regcache) <registers_owned>: New field. (init_register_cache, regcache_cpy): Declare. (regcache_read_pc, regcache_write_pc): Declare. (register_cache_size): Declare. (supply_regblock): Declare. * regcache.c (init_register_cache): New. (new_register_cache): Use it. (regcache_cpy): New. (register_cache_size): New. (supply_regblock): New. (regcache_read_pc, regcache_write_pc): New. * tracepoint.c: New. * Makefile.in (OBS): Add tracepoint.o. (tracepoint.o): New rule. gdb/ * regformats/regdat.sh: Include server.h. Don't include regcache.h.
2010-04-09 05:40:00 +02:00
int trace_event;
range stepping: gdbserver (x86 GNU/Linux) This patch adds support for range stepping to GDBserver, teaching it about vCont;r. It'd be easy to enable this for all hardware single-step targets without needing the linux_target_ops hook, however, at least PPC needs special care, due to the fact that PPC atomic sequences can't be hardware single-stepped through, a thing which GDBserver doesn't know about. So this leaves the support limited to x86/x86_64. gdb/ 2013-05-23 Pedro Alves <palves@redhat.com> * NEWS: Mention GDBserver range stepping support. gdb/gdbserver/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * linux-low.c (lwp_in_step_range): New function. (linux_wait_1): If the thread was range stepping and stopped outside the stepping range, report the stop to GDB. Otherwise, continue stepping. Add range stepping debug output. (linux_set_resume_request): Copy the step range from the resume request to the lwp. (linux_supports_range_stepping): New. (linux_target_ops) <supports_range_stepping>: Set to linux_supports_range_stepping. * linux-low.h (struct linux_target_ops) <supports_range_stepping>: New field. (struct lwp_info) <step_range_start, step_range_end>: New fields. * linux-x86-low.c (x86_supports_range_stepping): New. (the_low_target) <supports_range_stepping>: Set to x86_supports_range_stepping. * server.c (handle_v_cont): Handle 'r' action. (handle_v_requests): Append ";r" if the target supports range stepping. * target.h (struct thread_resume) <step_range_start, step_range_end>: New fields. (struct target_ops) <supports_range_stepping>: New field. (target_supports_range_stepping): New macro.
2013-05-23 19:17:50 +02:00
int in_step_range;
Implement TARGET_WAITKIND_NO_RESUMED in the remote protocol Testing with "maint set target-non-stop on" causes regressions in tests that rely on TARGET_WAITKIND_NO_RESUMED, which isn't modelled on the RSP. In real all-stop, gdbserver detects the situation and reporst error to GDB, and so the tests (e.g., gdb.threads/no-unwaited-for-left.exp) at fail quickly. But with "maint set target-non-stop on", GDB instead hangs forever waiting for a stop reply that never comes, and so the tests take longer to time out. This adds a new "N" stop reply packet that maps 1-1 to TARGET_WAITKIND_NO_RESUMED. gdb/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> PR 14618 * NEWS (New remote packets): Mention the N stop reply. * remote.c (remote_protocol_features): Add "no-resumed" entry. (remote_query_supported): Report no-resumed+ support. (remote_parse_stop_reply): Handle 'N'. (process_stop_reply): Handle TARGET_WAITKIND_NO_RESUMED. (remote_wait_as): Handle 'N' / TARGET_WAITKIND_NO_RESUMED. (_initialize_remote): Register "set/show remote no-resumed-stop-reply" commands. gdb/doc/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> PR 14618 * gdb.texinfo (Stop Reply Packets): Document the N stop reply. (Remote Configuration): Add the "set/show remote no-resumed-stop-reply" to the available settings table. (General Query Packets): Document the "no-resumed" qSupported feature. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> PR 14618 * linux-low.c (linux_wait_1): If the last resumed thread is gone, report TARGET_WAITKIND_NO_RESUMED. * remote-utils.c (prepare_resume_reply): Handle TARGET_WAITKIND_NO_RESUMED. * server.c (report_no_resumed): New global. (handle_query) <qSupported>: Handle "no-resumed+". Report "no-resumed+" support. (resume): When the target reports TARGET_WAITKIND_NO_RESUMED, only return error if the client doesn't support no-resumed events. (push_stop_notification): New function. (handle_target_event): Use it. Report TARGET_WAITKIND_NO_RESUMED events if the client supports them. gdb/testsuite/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * gdb.threads/no-unwaited-for-left.exp: Remove setup_kfail calls.
2015-11-30 17:05:25 +01:00
int any_resumed;
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
if (debug_threads)
{
debug_enter ();
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
debug_printf ("wait_1: [%s]\n", target_pid_to_str (ptid));
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
}
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
/* Translate generic target options into linux options. */
options = __WALL;
if (target_options & TARGET_WNOHANG)
options |= WNOHANG;
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
bp_explains_trap = 0;
trace_event = 0;
range stepping: gdbserver (x86 GNU/Linux) This patch adds support for range stepping to GDBserver, teaching it about vCont;r. It'd be easy to enable this for all hardware single-step targets without needing the linux_target_ops hook, however, at least PPC needs special care, due to the fact that PPC atomic sequences can't be hardware single-stepped through, a thing which GDBserver doesn't know about. So this leaves the support limited to x86/x86_64. gdb/ 2013-05-23 Pedro Alves <palves@redhat.com> * NEWS: Mention GDBserver range stepping support. gdb/gdbserver/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * linux-low.c (lwp_in_step_range): New function. (linux_wait_1): If the thread was range stepping and stopped outside the stepping range, report the stop to GDB. Otherwise, continue stepping. Add range stepping debug output. (linux_set_resume_request): Copy the step range from the resume request to the lwp. (linux_supports_range_stepping): New. (linux_target_ops) <supports_range_stepping>: Set to linux_supports_range_stepping. * linux-low.h (struct linux_target_ops) <supports_range_stepping>: New field. (struct lwp_info) <step_range_start, step_range_end>: New fields. * linux-x86-low.c (x86_supports_range_stepping): New. (the_low_target) <supports_range_stepping>: Set to x86_supports_range_stepping. * server.c (handle_v_cont): Handle 'r' action. (handle_v_requests): Append ";r" if the target supports range stepping. * target.h (struct thread_resume) <step_range_start, step_range_end>: New fields. (struct target_ops) <supports_range_stepping>: New field. (target_supports_range_stepping): New macro.
2013-05-23 19:17:50 +02:00
in_step_range = 0;
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
ourstatus->kind = TARGET_WAITKIND_IGNORE;
auto status_pending_p_any = [&] (thread_info *thread)
{
return status_pending_p_callback (thread, minus_one_ptid);
};
auto not_stopped = [&] (thread_info *thread)
{
return not_stopped_callback (thread, minus_one_ptid);
};
Implement TARGET_WAITKIND_NO_RESUMED in the remote protocol Testing with "maint set target-non-stop on" causes regressions in tests that rely on TARGET_WAITKIND_NO_RESUMED, which isn't modelled on the RSP. In real all-stop, gdbserver detects the situation and reporst error to GDB, and so the tests (e.g., gdb.threads/no-unwaited-for-left.exp) at fail quickly. But with "maint set target-non-stop on", GDB instead hangs forever waiting for a stop reply that never comes, and so the tests take longer to time out. This adds a new "N" stop reply packet that maps 1-1 to TARGET_WAITKIND_NO_RESUMED. gdb/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> PR 14618 * NEWS (New remote packets): Mention the N stop reply. * remote.c (remote_protocol_features): Add "no-resumed" entry. (remote_query_supported): Report no-resumed+ support. (remote_parse_stop_reply): Handle 'N'. (process_stop_reply): Handle TARGET_WAITKIND_NO_RESUMED. (remote_wait_as): Handle 'N' / TARGET_WAITKIND_NO_RESUMED. (_initialize_remote): Register "set/show remote no-resumed-stop-reply" commands. gdb/doc/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> PR 14618 * gdb.texinfo (Stop Reply Packets): Document the N stop reply. (Remote Configuration): Add the "set/show remote no-resumed-stop-reply" to the available settings table. (General Query Packets): Document the "no-resumed" qSupported feature. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> PR 14618 * linux-low.c (linux_wait_1): If the last resumed thread is gone, report TARGET_WAITKIND_NO_RESUMED. * remote-utils.c (prepare_resume_reply): Handle TARGET_WAITKIND_NO_RESUMED. * server.c (report_no_resumed): New global. (handle_query) <qSupported>: Handle "no-resumed+". Report "no-resumed+" support. (resume): When the target reports TARGET_WAITKIND_NO_RESUMED, only return error if the client doesn't support no-resumed events. (push_stop_notification): New function. (handle_target_event): Use it. Report TARGET_WAITKIND_NO_RESUMED events if the client supports them. gdb/testsuite/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * gdb.threads/no-unwaited-for-left.exp: Remove setup_kfail calls.
2015-11-30 17:05:25 +01:00
/* Find a resumed LWP, if any. */
if (find_thread (status_pending_p_any) != NULL)
Implement TARGET_WAITKIND_NO_RESUMED in the remote protocol Testing with "maint set target-non-stop on" causes regressions in tests that rely on TARGET_WAITKIND_NO_RESUMED, which isn't modelled on the RSP. In real all-stop, gdbserver detects the situation and reporst error to GDB, and so the tests (e.g., gdb.threads/no-unwaited-for-left.exp) at fail quickly. But with "maint set target-non-stop on", GDB instead hangs forever waiting for a stop reply that never comes, and so the tests take longer to time out. This adds a new "N" stop reply packet that maps 1-1 to TARGET_WAITKIND_NO_RESUMED. gdb/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> PR 14618 * NEWS (New remote packets): Mention the N stop reply. * remote.c (remote_protocol_features): Add "no-resumed" entry. (remote_query_supported): Report no-resumed+ support. (remote_parse_stop_reply): Handle 'N'. (process_stop_reply): Handle TARGET_WAITKIND_NO_RESUMED. (remote_wait_as): Handle 'N' / TARGET_WAITKIND_NO_RESUMED. (_initialize_remote): Register "set/show remote no-resumed-stop-reply" commands. gdb/doc/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> PR 14618 * gdb.texinfo (Stop Reply Packets): Document the N stop reply. (Remote Configuration): Add the "set/show remote no-resumed-stop-reply" to the available settings table. (General Query Packets): Document the "no-resumed" qSupported feature. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> PR 14618 * linux-low.c (linux_wait_1): If the last resumed thread is gone, report TARGET_WAITKIND_NO_RESUMED. * remote-utils.c (prepare_resume_reply): Handle TARGET_WAITKIND_NO_RESUMED. * server.c (report_no_resumed): New global. (handle_query) <qSupported>: Handle "no-resumed+". Report "no-resumed+" support. (resume): When the target reports TARGET_WAITKIND_NO_RESUMED, only return error if the client doesn't support no-resumed events. (push_stop_notification): New function. (handle_target_event): Use it. Report TARGET_WAITKIND_NO_RESUMED events if the client supports them. gdb/testsuite/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * gdb.threads/no-unwaited-for-left.exp: Remove setup_kfail calls.
2015-11-30 17:05:25 +01:00
any_resumed = 1;
else if (find_thread (not_stopped) != NULL)
Implement TARGET_WAITKIND_NO_RESUMED in the remote protocol Testing with "maint set target-non-stop on" causes regressions in tests that rely on TARGET_WAITKIND_NO_RESUMED, which isn't modelled on the RSP. In real all-stop, gdbserver detects the situation and reporst error to GDB, and so the tests (e.g., gdb.threads/no-unwaited-for-left.exp) at fail quickly. But with "maint set target-non-stop on", GDB instead hangs forever waiting for a stop reply that never comes, and so the tests take longer to time out. This adds a new "N" stop reply packet that maps 1-1 to TARGET_WAITKIND_NO_RESUMED. gdb/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> PR 14618 * NEWS (New remote packets): Mention the N stop reply. * remote.c (remote_protocol_features): Add "no-resumed" entry. (remote_query_supported): Report no-resumed+ support. (remote_parse_stop_reply): Handle 'N'. (process_stop_reply): Handle TARGET_WAITKIND_NO_RESUMED. (remote_wait_as): Handle 'N' / TARGET_WAITKIND_NO_RESUMED. (_initialize_remote): Register "set/show remote no-resumed-stop-reply" commands. gdb/doc/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> PR 14618 * gdb.texinfo (Stop Reply Packets): Document the N stop reply. (Remote Configuration): Add the "set/show remote no-resumed-stop-reply" to the available settings table. (General Query Packets): Document the "no-resumed" qSupported feature. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> PR 14618 * linux-low.c (linux_wait_1): If the last resumed thread is gone, report TARGET_WAITKIND_NO_RESUMED. * remote-utils.c (prepare_resume_reply): Handle TARGET_WAITKIND_NO_RESUMED. * server.c (report_no_resumed): New global. (handle_query) <qSupported>: Handle "no-resumed+". Report "no-resumed+" support. (resume): When the target reports TARGET_WAITKIND_NO_RESUMED, only return error if the client doesn't support no-resumed events. (push_stop_notification): New function. (handle_target_event): Use it. Report TARGET_WAITKIND_NO_RESUMED events if the client supports them. gdb/testsuite/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * gdb.threads/no-unwaited-for-left.exp: Remove setup_kfail calls.
2015-11-30 17:05:25 +01:00
any_resumed = 1;
else
any_resumed = 0;
2018-06-11 22:45:22 +02:00
if (step_over_bkpt == null_ptid)
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
pid = wait_for_event (ptid, &w, options);
else
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("step_over_bkpt set [%s], doing a blocking wait\n",
target_pid_to_str (step_over_bkpt));
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
pid = wait_for_event (step_over_bkpt, &w, options & ~WNOHANG);
}
Implement TARGET_WAITKIND_NO_RESUMED in the remote protocol Testing with "maint set target-non-stop on" causes regressions in tests that rely on TARGET_WAITKIND_NO_RESUMED, which isn't modelled on the RSP. In real all-stop, gdbserver detects the situation and reporst error to GDB, and so the tests (e.g., gdb.threads/no-unwaited-for-left.exp) at fail quickly. But with "maint set target-non-stop on", GDB instead hangs forever waiting for a stop reply that never comes, and so the tests take longer to time out. This adds a new "N" stop reply packet that maps 1-1 to TARGET_WAITKIND_NO_RESUMED. gdb/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> PR 14618 * NEWS (New remote packets): Mention the N stop reply. * remote.c (remote_protocol_features): Add "no-resumed" entry. (remote_query_supported): Report no-resumed+ support. (remote_parse_stop_reply): Handle 'N'. (process_stop_reply): Handle TARGET_WAITKIND_NO_RESUMED. (remote_wait_as): Handle 'N' / TARGET_WAITKIND_NO_RESUMED. (_initialize_remote): Register "set/show remote no-resumed-stop-reply" commands. gdb/doc/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> PR 14618 * gdb.texinfo (Stop Reply Packets): Document the N stop reply. (Remote Configuration): Add the "set/show remote no-resumed-stop-reply" to the available settings table. (General Query Packets): Document the "no-resumed" qSupported feature. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> PR 14618 * linux-low.c (linux_wait_1): If the last resumed thread is gone, report TARGET_WAITKIND_NO_RESUMED. * remote-utils.c (prepare_resume_reply): Handle TARGET_WAITKIND_NO_RESUMED. * server.c (report_no_resumed): New global. (handle_query) <qSupported>: Handle "no-resumed+". Report "no-resumed+" support. (resume): When the target reports TARGET_WAITKIND_NO_RESUMED, only return error if the client doesn't support no-resumed events. (push_stop_notification): New function. (handle_target_event): Use it. Report TARGET_WAITKIND_NO_RESUMED events if the client supports them. gdb/testsuite/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * gdb.threads/no-unwaited-for-left.exp: Remove setup_kfail calls.
2015-11-30 17:05:25 +01:00
if (pid == 0 || (pid == -1 && !any_resumed))
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
{
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
gdb_assert (target_options & TARGET_WNOHANG);
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
if (debug_threads)
{
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
debug_printf ("wait_1 ret = null_ptid, "
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
"TARGET_WAITKIND_IGNORE\n");
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_exit ();
}
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
ourstatus->kind = TARGET_WAITKIND_IGNORE;
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
return null_ptid;
}
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
else if (pid == -1)
{
if (debug_threads)
{
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
debug_printf ("wait_1 ret = null_ptid, "
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
"TARGET_WAITKIND_NO_RESUMED\n");
debug_exit ();
}
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
ourstatus->kind = TARGET_WAITKIND_NO_RESUMED;
return null_ptid;
}
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
event_child = get_thread_lwp (current_thread);
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
/* wait_for_event only returns an exit status for the last
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
child of a process. Report it. */
if (WIFEXITED (w) || WIFSIGNALED (w))
{
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
if (WIFEXITED (w))
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
{
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
ourstatus->kind = TARGET_WAITKIND_EXITED;
ourstatus->value.integer = WEXITSTATUS (w);
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
if (debug_threads)
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
{
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
debug_printf ("wait_1 ret = %s, exited with "
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
"retcode %d\n",
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
target_pid_to_str (ptid_of (current_thread)),
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
WEXITSTATUS (w));
debug_exit ();
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
}
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
}
else
{
ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
ourstatus->value.sig = gdb_signal_from_host (WTERMSIG (w));
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
if (debug_threads)
{
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
debug_printf ("wait_1 ret = %s, terminated with "
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
"signal %d\n",
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
target_pid_to_str (ptid_of (current_thread)),
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
WTERMSIG (w));
debug_exit ();
}
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
}
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
Remote thread create/exit events When testing with "maint set target-non-stop on", a few threading-related tests expose an issue that requires new RSP packets. Say there are 3 threads running, 1-3. If GDB tries to stop thread 1, 2 and 3, and then waits for their stops, but meanwhile say, thread 2 exits, GDB hangs forever waiting for a stop for thread 2 that won't ever happen. This patch fixes the issue by adding support for thread exit events to the protocol. However, we don't want these always enabled, as they're useless most of the time, and would slow down remote debugging. So I made it so that GDB can enable/disable them, and then made gdb do that around the cases that need it, which currently is only infrun.c:stop_all_threads. In turn, if we have thread exit events, then the extra "thread x exited" traffic slows down attach-many-short-lived-threads.exp enough that gdb has trouble keeping up with new threads that are spawned while gdb tries to stop existing ones. To fix that I added support for the counterpart thread created events too. Enabling those when we try to stop threads ensures that new threads never get a chance to themselves start new threads, killing the race. gdb/doc/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): List "set/show remote thread-events" command in configuration table. (Stop Reply Packets): Document "T05 create" stop reason and 'w' stop reply. (General Query Packets): Document QThreadEvents packet. Document QThreadEvents qSupported feature. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. If GDB wants to hear about thread create events, leave the new child's status pending. (linux_low_filter_event): If GDB wants to hear about thread exit events, leave the LWP marked dead and don't delete it. (linux_wait_for_event_filtered): Don't check for thread exit. (filter_exit_event): New function. (linux_wait_1): Use it, when returning an exit event. (linux_resume_one_lwp_throw): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. * remote-utils.c (prepare_resume_reply): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.c (report_thread_events): New global. (handle_general_set): Handle QThreadEvents. (handle_query) <qSupported>: Handle and report QThreadEvents+; (handle_target_event): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.h (report_thread_events): Declare. gdb/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * NEWS (New commands): Mention "set/show remote thread-events" commands. (New remote packets): Mention thread created/exited stop reasons and QThreadEvents packet. * infrun.c (disable_thread_events): New function. (stop_all_threads): Disable/enable thread create/exit events. Handle TARGET_WAITKIND_THREAD_EXITED. (handle_inferior_event_1): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * remote.c (remove_child_of_pending_fork): Also remove threads of threads that have TARGET_WAITKIND_THREAD_EXITED events. (remote_parse_stop_reply): Handle "create" magic register. Handle 'w' stop reply. (initialize_remote): Install remote_thread_events as to_thread_events target hook. (remote_thread_events): New function. * target-delegates.c: Regenerate. * target.c (target_thread_events): New function. * target.h (struct target_ops) <to_thread_events>: New field. (target_thread_events): Declare. * target/waitstatus.c (target_waitstatus_to_string): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * target/waitstatus.h (enum target_waitkind) <TARGET_WAITKIND_THREAD_CREATED, TARGET_WAITKIND_THREAD_EXITED): New values.
2015-11-30 17:05:21 +01:00
if (ourstatus->kind == TARGET_WAITKIND_EXITED)
return filter_exit_event (event_child, ourstatus);
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
return ptid_of (current_thread);
}
Fix instruction skipping when using software single step in GDBServer Without this patch, when doing a software single step, with for example a conditional breakpoint, gdbserver would wrongly avance the pc of breakpoint_len and skips an instruction. This is due to gdbserver assuming that it's hardware single stepping. When it resumes from the breakpoint address it expects the trap to be caused by ptrace and if it's rather caused by a software breakpoint it assumes this is a permanent breakpoint and that it needs to skip over it. However when software single stepping, this breakpoint is legitimate as it's the reinsert breakpoint gdbserver has put in place to break at the next instruction. Thus gdbserver wrongly advances the pc and skips an instruction. This patch fixes this behavior so that gdbserver checks if it is a reinsert breakpoint from software single stepping. If it is it won't advance the pc. And if there's no reinsert breakpoint there we assume then that it's a permanent breakpoint and advance the pc. Here's a commented log of what would happen before and after the fix on gdbserver : /* Here there is a conditional breakpoint at 0x10428 that needs to be stepped over. */ Need step over [LWP 11204]? yes, found breakpoint at 0x10428 ... /* e7f001f0 is a breakpoint instruction on arm Here gdbserver writes the software breakpoint we would like to hit */ Writing e7f001f0 to 0x0001042c in process 11204 ... Resuming lwp 11220 (continue, signal 0, stop not expected) pending reinsert at 0x10428 stop pc is 00010428 continue from pc 0x10428 ... /* Here gdbserver hit the software breakpoint that was in place for the step over */ stop pc is 0001042c pc is 0x1042c step-over for LWP 11220.11220 executed software breakpoint Finished step over. Could not find fast tracepoint jump at 0x10428 in list (reinserting). /* Here gdbserver writes back the original instruction */ Writing e50b3008 to 0x0001042c in process 11220 Step-over finished. Need step over [LWP 11220]? No /* Here because gdbserver assumes this is a permenant breakpoint it advances the pc of breakpoint_len, in this case 4 bytes, so we have just skipped the instruction that was written back here : Writing e50b3008 to 0x0001042c in process 11220 */ stop pc is 00010430 pc is 0x10430 Need step over [LWP 11220]? No, no breakpoint found at 0x10430 Proceeding, no step-over needed proceed_one_lwp: lwp 11220 stop pc is 00010430 This patch fixes this situation and we get the right behavior : Writing e50b3008 to 0x0001042c in process 11245 Hit a gdbserver breakpoint. Hit a gdbserver breakpoint. Step-over finished. proceeding all threads. Need step over [LWP 11245]? No stop pc is 0001042c pc is 0x1042c Need step over [LWP 11245]? No, no breakpoint found at 0x1042c Proceeding, no step-over needed proceed_one_lwp: lwp 11245 stop pc is 0001042c pc is 0x1042c Resuming lwp 11245 (continue, signal 0, stop not expected) stop pc is 0001042c continue from pc 0x1042c It also works if the value at 0x0001042c is a permanent breakpoint. If so gdbserver will finish the step over, remove the reinserted breakpoint, resume at that location and on the next SIGTRAP gdbserver will trigger the advance PC condition as reinsert_breakpoint_inserted_here will be false. I also tested this against bp-permanent.exp on arm (with a work in progress software single step patchset) without any regressions. It's also tested against x86 bp-permanent.exp without any regression. So both software and hardware single step are tested. No regressions on Ubuntu 14.04 on ARMv7 and x86. With gdbserver-{native,extended} / { -marm -mthumb } gdb/gdbserver/ChangeLog: * linux-low.c (linux_wait_1): Fix pc advance condition. * mem-break.c (reinsert_breakpoint_inserted_here): New function. * mem-break.h (reinsert_breakpoint_inserted_here): New declaration.
2015-11-30 21:16:22 +01:00
/* If step-over executes a breakpoint instruction, in the case of a
hardware single step it means a gdb/gdbserver breakpoint had been
planted on top of a permanent breakpoint, in the case of a software
single step it may just mean that gdbserver hit the reinsert breakpoint.
Handle MIPS Linux SIGTRAP siginfo.si_code values This unbreaks pending/delayed breakpoints handling, as well as hardware watchpoints, on MIPS. Ref: https://sourceware.org/ml/gdb-patches/2016-02/msg00681.html The MIPS kernel reports SI_KERNEL for all kernel generated traps, instead of TRAP_BRKPT / TRAP_HWBKPT, but GDB isn't aware of this. Basically, this commit: - Folds watchpoints logic into check_stopped_by_breakpoint, and renames it to save_stop_reason. - Adds GDB_ARCH_IS_TRAP_HWBKPT. - Makes MIPS set both GDB_ARCH_IS_TRAP_BRPT and GDB_ARCH_IS_TRAP_HWBKPT to SI_KERNEL. In save_stop_reason, we handle the case of the same si_code returning true for both TRAP_BRPT and TRAP_HWBKPT by looking at what the debug registers say. Tested on x86-64 Fedora 20, native and gdbserver. gdb/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-nat.c (save_sigtrap) Delete. (stop_wait_callback): Call save_stop_reason instead of save_sigtrap. (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Bits of save_sigtrap folded here. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_nat_filter_event): Call save_stop_reason instead of save_sigtrap. * nat/linux-ptrace.h: Check for both SI_KERNEL and TRAP_BRKPT si_code for MIPS. * nat/linux-ptrace.h: Fix "TRAP_HWBPT" typo in x86 table. Add comments on MIPS behavior. (GDB_ARCH_IS_TRAP_HWBKPT): Define for all archs. gdb/gdbserver/ChangeLog: 2016-02-24 Pedro Alves <palves@redhat.com> * linux-low.c (check_stopped_by_breakpoint): Rename to ... (save_stop_reason): ... this. Use GDB_ARCH_IS_TRAP_HWBKPT and handle ambiguous GDB_ARCH_IS_TRAP_BRKPT / GDB_ARCH_IS_TRAP_HWBKPT. Factor out common code between the USE_SIGTRAP_SIGINFO and !USE_SIGTRAP_SIGINFO blocks. (linux_low_filter_event): Call save_stop_reason instead of check_stopped_by_breakpoint and check_stopped_by_watchpoint. Update comments. (linux_wait_1): Update comments.
2016-02-24 23:52:06 +01:00
The PC has been adjusted by save_stop_reason to point at
Fix instruction skipping when using software single step in GDBServer Without this patch, when doing a software single step, with for example a conditional breakpoint, gdbserver would wrongly avance the pc of breakpoint_len and skips an instruction. This is due to gdbserver assuming that it's hardware single stepping. When it resumes from the breakpoint address it expects the trap to be caused by ptrace and if it's rather caused by a software breakpoint it assumes this is a permanent breakpoint and that it needs to skip over it. However when software single stepping, this breakpoint is legitimate as it's the reinsert breakpoint gdbserver has put in place to break at the next instruction. Thus gdbserver wrongly advances the pc and skips an instruction. This patch fixes this behavior so that gdbserver checks if it is a reinsert breakpoint from software single stepping. If it is it won't advance the pc. And if there's no reinsert breakpoint there we assume then that it's a permanent breakpoint and advance the pc. Here's a commented log of what would happen before and after the fix on gdbserver : /* Here there is a conditional breakpoint at 0x10428 that needs to be stepped over. */ Need step over [LWP 11204]? yes, found breakpoint at 0x10428 ... /* e7f001f0 is a breakpoint instruction on arm Here gdbserver writes the software breakpoint we would like to hit */ Writing e7f001f0 to 0x0001042c in process 11204 ... Resuming lwp 11220 (continue, signal 0, stop not expected) pending reinsert at 0x10428 stop pc is 00010428 continue from pc 0x10428 ... /* Here gdbserver hit the software breakpoint that was in place for the step over */ stop pc is 0001042c pc is 0x1042c step-over for LWP 11220.11220 executed software breakpoint Finished step over. Could not find fast tracepoint jump at 0x10428 in list (reinserting). /* Here gdbserver writes back the original instruction */ Writing e50b3008 to 0x0001042c in process 11220 Step-over finished. Need step over [LWP 11220]? No /* Here because gdbserver assumes this is a permenant breakpoint it advances the pc of breakpoint_len, in this case 4 bytes, so we have just skipped the instruction that was written back here : Writing e50b3008 to 0x0001042c in process 11220 */ stop pc is 00010430 pc is 0x10430 Need step over [LWP 11220]? No, no breakpoint found at 0x10430 Proceeding, no step-over needed proceed_one_lwp: lwp 11220 stop pc is 00010430 This patch fixes this situation and we get the right behavior : Writing e50b3008 to 0x0001042c in process 11245 Hit a gdbserver breakpoint. Hit a gdbserver breakpoint. Step-over finished. proceeding all threads. Need step over [LWP 11245]? No stop pc is 0001042c pc is 0x1042c Need step over [LWP 11245]? No, no breakpoint found at 0x1042c Proceeding, no step-over needed proceed_one_lwp: lwp 11245 stop pc is 0001042c pc is 0x1042c Resuming lwp 11245 (continue, signal 0, stop not expected) stop pc is 0001042c continue from pc 0x1042c It also works if the value at 0x0001042c is a permanent breakpoint. If so gdbserver will finish the step over, remove the reinserted breakpoint, resume at that location and on the next SIGTRAP gdbserver will trigger the advance PC condition as reinsert_breakpoint_inserted_here will be false. I also tested this against bp-permanent.exp on arm (with a work in progress software single step patchset) without any regressions. It's also tested against x86 bp-permanent.exp without any regression. So both software and hardware single step are tested. No regressions on Ubuntu 14.04 on ARMv7 and x86. With gdbserver-{native,extended} / { -marm -mthumb } gdb/gdbserver/ChangeLog: * linux-low.c (linux_wait_1): Fix pc advance condition. * mem-break.c (reinsert_breakpoint_inserted_here): New function. * mem-break.h (reinsert_breakpoint_inserted_here): New declaration.
2015-11-30 21:16:22 +01:00
the breakpoint address.
So in the case of the hardware single step advance the PC manually
past the breakpoint and in the case of software single step advance only
if it's not the single_step_breakpoint we are hitting.
Fix instruction skipping when using software single step in GDBServer Without this patch, when doing a software single step, with for example a conditional breakpoint, gdbserver would wrongly avance the pc of breakpoint_len and skips an instruction. This is due to gdbserver assuming that it's hardware single stepping. When it resumes from the breakpoint address it expects the trap to be caused by ptrace and if it's rather caused by a software breakpoint it assumes this is a permanent breakpoint and that it needs to skip over it. However when software single stepping, this breakpoint is legitimate as it's the reinsert breakpoint gdbserver has put in place to break at the next instruction. Thus gdbserver wrongly advances the pc and skips an instruction. This patch fixes this behavior so that gdbserver checks if it is a reinsert breakpoint from software single stepping. If it is it won't advance the pc. And if there's no reinsert breakpoint there we assume then that it's a permanent breakpoint and advance the pc. Here's a commented log of what would happen before and after the fix on gdbserver : /* Here there is a conditional breakpoint at 0x10428 that needs to be stepped over. */ Need step over [LWP 11204]? yes, found breakpoint at 0x10428 ... /* e7f001f0 is a breakpoint instruction on arm Here gdbserver writes the software breakpoint we would like to hit */ Writing e7f001f0 to 0x0001042c in process 11204 ... Resuming lwp 11220 (continue, signal 0, stop not expected) pending reinsert at 0x10428 stop pc is 00010428 continue from pc 0x10428 ... /* Here gdbserver hit the software breakpoint that was in place for the step over */ stop pc is 0001042c pc is 0x1042c step-over for LWP 11220.11220 executed software breakpoint Finished step over. Could not find fast tracepoint jump at 0x10428 in list (reinserting). /* Here gdbserver writes back the original instruction */ Writing e50b3008 to 0x0001042c in process 11220 Step-over finished. Need step over [LWP 11220]? No /* Here because gdbserver assumes this is a permenant breakpoint it advances the pc of breakpoint_len, in this case 4 bytes, so we have just skipped the instruction that was written back here : Writing e50b3008 to 0x0001042c in process 11220 */ stop pc is 00010430 pc is 0x10430 Need step over [LWP 11220]? No, no breakpoint found at 0x10430 Proceeding, no step-over needed proceed_one_lwp: lwp 11220 stop pc is 00010430 This patch fixes this situation and we get the right behavior : Writing e50b3008 to 0x0001042c in process 11245 Hit a gdbserver breakpoint. Hit a gdbserver breakpoint. Step-over finished. proceeding all threads. Need step over [LWP 11245]? No stop pc is 0001042c pc is 0x1042c Need step over [LWP 11245]? No, no breakpoint found at 0x1042c Proceeding, no step-over needed proceed_one_lwp: lwp 11245 stop pc is 0001042c pc is 0x1042c Resuming lwp 11245 (continue, signal 0, stop not expected) stop pc is 0001042c continue from pc 0x1042c It also works if the value at 0x0001042c is a permanent breakpoint. If so gdbserver will finish the step over, remove the reinserted breakpoint, resume at that location and on the next SIGTRAP gdbserver will trigger the advance PC condition as reinsert_breakpoint_inserted_here will be false. I also tested this against bp-permanent.exp on arm (with a work in progress software single step patchset) without any regressions. It's also tested against x86 bp-permanent.exp without any regression. So both software and hardware single step are tested. No regressions on Ubuntu 14.04 on ARMv7 and x86. With gdbserver-{native,extended} / { -marm -mthumb } gdb/gdbserver/ChangeLog: * linux-low.c (linux_wait_1): Fix pc advance condition. * mem-break.c (reinsert_breakpoint_inserted_here): New function. * mem-break.h (reinsert_breakpoint_inserted_here): New declaration.
2015-11-30 21:16:22 +01:00
This avoids that a program would keep trapping a permanent breakpoint
forever. */
2018-06-11 22:45:22 +02:00
if (step_over_bkpt != null_ptid
Fix instruction skipping when using software single step in GDBServer Without this patch, when doing a software single step, with for example a conditional breakpoint, gdbserver would wrongly avance the pc of breakpoint_len and skips an instruction. This is due to gdbserver assuming that it's hardware single stepping. When it resumes from the breakpoint address it expects the trap to be caused by ptrace and if it's rather caused by a software breakpoint it assumes this is a permanent breakpoint and that it needs to skip over it. However when software single stepping, this breakpoint is legitimate as it's the reinsert breakpoint gdbserver has put in place to break at the next instruction. Thus gdbserver wrongly advances the pc and skips an instruction. This patch fixes this behavior so that gdbserver checks if it is a reinsert breakpoint from software single stepping. If it is it won't advance the pc. And if there's no reinsert breakpoint there we assume then that it's a permanent breakpoint and advance the pc. Here's a commented log of what would happen before and after the fix on gdbserver : /* Here there is a conditional breakpoint at 0x10428 that needs to be stepped over. */ Need step over [LWP 11204]? yes, found breakpoint at 0x10428 ... /* e7f001f0 is a breakpoint instruction on arm Here gdbserver writes the software breakpoint we would like to hit */ Writing e7f001f0 to 0x0001042c in process 11204 ... Resuming lwp 11220 (continue, signal 0, stop not expected) pending reinsert at 0x10428 stop pc is 00010428 continue from pc 0x10428 ... /* Here gdbserver hit the software breakpoint that was in place for the step over */ stop pc is 0001042c pc is 0x1042c step-over for LWP 11220.11220 executed software breakpoint Finished step over. Could not find fast tracepoint jump at 0x10428 in list (reinserting). /* Here gdbserver writes back the original instruction */ Writing e50b3008 to 0x0001042c in process 11220 Step-over finished. Need step over [LWP 11220]? No /* Here because gdbserver assumes this is a permenant breakpoint it advances the pc of breakpoint_len, in this case 4 bytes, so we have just skipped the instruction that was written back here : Writing e50b3008 to 0x0001042c in process 11220 */ stop pc is 00010430 pc is 0x10430 Need step over [LWP 11220]? No, no breakpoint found at 0x10430 Proceeding, no step-over needed proceed_one_lwp: lwp 11220 stop pc is 00010430 This patch fixes this situation and we get the right behavior : Writing e50b3008 to 0x0001042c in process 11245 Hit a gdbserver breakpoint. Hit a gdbserver breakpoint. Step-over finished. proceeding all threads. Need step over [LWP 11245]? No stop pc is 0001042c pc is 0x1042c Need step over [LWP 11245]? No, no breakpoint found at 0x1042c Proceeding, no step-over needed proceed_one_lwp: lwp 11245 stop pc is 0001042c pc is 0x1042c Resuming lwp 11245 (continue, signal 0, stop not expected) stop pc is 0001042c continue from pc 0x1042c It also works if the value at 0x0001042c is a permanent breakpoint. If so gdbserver will finish the step over, remove the reinserted breakpoint, resume at that location and on the next SIGTRAP gdbserver will trigger the advance PC condition as reinsert_breakpoint_inserted_here will be false. I also tested this against bp-permanent.exp on arm (with a work in progress software single step patchset) without any regressions. It's also tested against x86 bp-permanent.exp without any regression. So both software and hardware single step are tested. No regressions on Ubuntu 14.04 on ARMv7 and x86. With gdbserver-{native,extended} / { -marm -mthumb } gdb/gdbserver/ChangeLog: * linux-low.c (linux_wait_1): Fix pc advance condition. * mem-break.c (reinsert_breakpoint_inserted_here): New function. * mem-break.h (reinsert_breakpoint_inserted_here): New declaration.
2015-11-30 21:16:22 +01:00
&& event_child->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT
&& (event_child->stepping
|| !single_step_breakpoint_inserted_here (event_child->stop_pc)))
{
Add the target_ops needed for software breakpoints in GDBServer. This patch is in preparation for software breakpoints on ARM linux. It refactors breakpoint and breakpoint_len into breakpoint_kind_from_pc and sw_breakpoint_from kind to prepare the case where we have multiple types of breakpoints. Kind is the type of breakpoint (hardware or software) to be inserted, usually it is the lenght of the software breakpoint but can be something else depending on the target. This patch introduces the linux_target_ops breakpoint_kind_from_pc and sw_breakpoint_from_kind. breakpoint_kind_from_pc returns the breakpoint kind and adjusts the PC to the real memory location in case a flag was present in the PC. E.g the instruction mode on ARM. sw_breakpoint_from_kind returns the software breakpoint for this kind as a string of bytes, the length of the breakpoint is adjusted for the breakpoint's size in memory. For targets that have only one kind of breakpoint, the default value 0 is returned by linux_breakpoint_kind_from_pc so that not all targets need to implement the breakpoint_kind_from_pc operation. No regressions, tested on Ubuntu 14.04 on ARMv7 and x86 With gdbserver-{native,extended} / { -marm -mthumb } Also since the target_ops have been changed compilation was tested on affected archs namely : aarch64, arm, bfin, cris, crisv32, m32r, m68k, mips, nios2, ppc, s390, sparc, tic6x, tile, x86, steins. Not tested : sh gdb/gdbserver/ChangeLog: * linux-aarch64-low.c (aarch64_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-arm-low.c (arm_breakpoint_kind_from_pc): New function. (arm_sw_breakpoint_from_kind): New function. * linux-bfin-low.c (bfin_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-cris-low.c (cris_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-crisv32-low.c (cris_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-low.c (linux_wait_1): Call breakpoint_kind_from_pc and sw_breakpoint_from_kind to increment the pc. (linux_breakpoint_kind_from_pc): New function. (linux_sw_breakpoint_from_kind): New function. (struct target_ops) <sw_breakpoint_from_kind>: Initialize field. (initialize_low): Call breakpoint_kind_from_pc and sw_breakpoint_from_kind to replace breakpoint_data/len. * linux-low.h (struct linux_target_ops) <breakpoint_kind_from_pc>: New field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Likewise. * linux-m32r-low.c (m32r_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-m68k-low.c (m68k_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-mips-low.c (mips_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-nios2-low.c (nios2_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-ppc-low.c (ppc_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-s390-low.c (s390_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-sh-low.c (sh_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-sparc-low.c (sparc_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-tic6x-low.c (tic6x_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-tile-low.c (tile_sw_breakpoint_from_kind): New function. * linux-x86-low.c (x86_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-xtensa-low.c (xtensa_sw_breakpoint_from_kind) New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
2015-10-21 17:17:26 +02:00
int increment_pc = 0;
int breakpoint_kind = 0;
CORE_ADDR stop_pc = event_child->stop_pc;
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
breakpoint_kind = breakpoint_kind_from_current_state (&stop_pc);
sw_breakpoint_from_kind (breakpoint_kind, &increment_pc);
if (debug_threads)
{
debug_printf ("step-over for %s executed software breakpoint\n",
target_pid_to_str (ptid_of (current_thread)));
}
if (increment_pc != 0)
{
struct regcache *regcache
= get_thread_regcache (current_thread, 1);
event_child->stop_pc += increment_pc;
gdbserver/linux-low: turn 'get_pc' and 'set_pc' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_pc' and 'set_pc' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. * linux-low.cc (supports_breakpoints): Turn into... (linux_process_target::low_supports_breakpoints): ...this. (linux_process_target::low_get_pc): Define. (linux_process_target::low_set_pc): Define. Update the callers below. (linux_process_target::get_pc) (linux_process_target::save_stop_reason) (linux_process_target::maybe_move_out_of_jump_pad) (linux_process_target::wait_1) (linux_process_target::resume_one_lwp_throw) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (linux_process_target::read_pc) (linux_process_target::write_pc) * linux-x86-low.cc (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (x86_target::low_supports_breakpoints): Define. (x86_get_pc): Turn into... (x86_target::low_get_pc): ...this. (x86_set_pc): Turn into... (x86_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (arm_target::low_supports_breakpoints) (arm_target::low_get_pc) (arm_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (bfin_target::low_supports_breakpoints) (bfin_target::low_get_pc) (bfin_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (cris_target::low_supports_breakpoints) (cris_target::low_get_pc) (cris_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (crisv32_target::low_supports_breakpoints) (crisv32_target::low_get_pc) (crisv32_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m32r_target::low_supports_breakpoints) (m32r_target::low_get_pc) (m32r_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m68k_target::low_supports_breakpoints) (m68k_target::low_get_pc) (m68k_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (nios2_target::low_supports_breakpoints) (nios2_target::low_get_pc) (nios2_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (sh_target::low_supports_breakpoints) (sh_target::low_get_pc) (sh_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (xtensa_target::low_supports_breakpoints) (xtensa_target::low_get_pc) (xtensa_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_supports_breakpoints> <low_get_pc>: Declare. (sparc_target::low_supports_breakpoints) (sparc_target::low_get_pc): Define. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tile_target::low_supports_breakpoints) (tile_target::low_get_pc) (tile_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (aarch64_target::low_supports_breakpoints): Define. (aarch64_get_pc): Turn into... (aarch64_target::low_get_pc): ...this. (aarch64_set_pc): Turn into... (aarch64_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (mips_target::low_supports_breakpoints): Define. (mips_get_pc): Turn into... (mips_target::low_get_pc): ...this. (mips_set_pc): Turn into... (mips_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (ppc_target::low_supports_breakpoints): Define. (ppc_get_pc): Turn into... (ppc_target::low_get_pc): ...this. (ppc_set_pc): Turn into... (ppc_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (riscv_target::low_supports_breakpoints): Define. (riscv_get_pc): Turn into... (riscv_target::low_get_pc): ...this. (riscv_set_pc): Turn into... (riscv_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (s390_target::low_supports_breakpoints): Define. (s390_get_pc): Turn into... (s390_target::low_get_pc): ...this. (s390_set_pc): Turn into... (s390_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tic6x_target::low_supports_breakpoints): Define. (tic6x_get_pc): Turn into... (tic6x_target::low_get_pc): ...this. (tic6x_set_pc): Turn into... (tic6x_target::low_set_pc): ...this. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
low_set_pc (regcache, event_child->stop_pc);
gdbserver/linux-low: turn 'breakpoint_at' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'breakpoint_at' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <low_breakpoint_at>: Declare. Update the callers below: * linux-low.cc (linux_process_target::save_stop_reason) (linux_process_target::thread_still_has_status_pending) (linux_process_target::wait_1) * linux-x86-low.cc (class x86_target) <low_breakpoint_at>: Declare. (x86_breakpoint_at): Turn into... (x86_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <low_breakpoint_at>: Declare. (aarch64_breakpoint_at): Turn into... (aarch64_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (class arm_target) <low_breakpoint_at>: Declare. (arm_target::low_breakpoint_at): Define. (the_low_target): Remove the op field. * linux-bfin-low.cc (class bfin_target) <low_breakpoint_at>: Declare. (bfin_breakpoint_at): Turn into... (bfin_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-cris-low.cc (class cris_target) <low_breakpoint_at>: Declare. (cris_breakpoint_at): Turn into... (cris_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-crisv32-low.cc (class crisv32_target) <low_breakpoint_at>: Declare. (crisv32_breakpoint_at): Turn into... (crisv32_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-ia64-low.cc (class ia64_target) <low_breakpoint_at>: Declare. (ia64_target::low_breakpoint_at): Define. * linux-m32r-low.cc (class m32r_target) <low_breakpoint_at>: Declare. (m32r_breakpoint_at): Turn into... (m32r_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-m68k-low.cc (class m68k_target) <low_breakpoint_at>: Declare. (m68k_breakpoint_at): Turn into... (m68k_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-mips-low.cc (class mips_target) <low_breakpoint_at>: Declare. (mips_breakpoint_at): Turn into... (mips_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-nios2-low.cc (class nios2_target) <low_breakpoint_at>: Declare. (nios2_breakpoint_at): Turn into... (nios2_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (class ppc_target) <low_breakpoint_at>: Declare. (ppc_breakpoint_at): Turn into... (ppc_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-riscv-low.cc (class riscv_target) <low_breakpoint_at>: Declare. (riscv_breakpoint_at): Turn into... (riscv_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-s390-low.cc (class s390_target) <low_breakpoint_at>: Declare. (s390_breakpoint_at): Turn into... (s390_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-sh-low.cc (class sh_target) <low_breakpoint_at>: Declare. (sh_breakpoint_at): Turn into... (sh_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-sparc-low.cc (class sparc_target) <low_breakpoint_at>: Declare. (sparc_breakpoint_at): Turn into... (sparc_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-tic6x-low.cc (class tic6x_target) <low_breakpoint_at>: Declare. (tic6x_breakpoint_at): Turn into... (tic6x_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-tile-low.cc (class tile_target) <low_breakpoint_at>: Declare. (tile_breakpoint_at): Turn into... (tile_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-xtensa-low.cc (class xtensa_target) <low_breakpoint_at>: Declare. (xtensa_breakpoint_at): Turn into... (xtensa_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field.
2020-04-02 15:11:26 +02:00
if (!low_breakpoint_at (event_child->stop_pc))
event_child->stop_reason = TARGET_STOPPED_BY_NO_REASON;
}
}
/* If this event was not handled before, and is not a SIGTRAP, we
report it. SIGILL and SIGSEGV are also treated as traps in case
a breakpoint is inserted at the current PC. If this target does
not support internal breakpoints at all, we also report the
SIGTRAP without further processing; it's of no concern to us. */
maybe_internal_trap
gdbserver/linux-low: turn 'get_pc' and 'set_pc' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_pc' and 'set_pc' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. * linux-low.cc (supports_breakpoints): Turn into... (linux_process_target::low_supports_breakpoints): ...this. (linux_process_target::low_get_pc): Define. (linux_process_target::low_set_pc): Define. Update the callers below. (linux_process_target::get_pc) (linux_process_target::save_stop_reason) (linux_process_target::maybe_move_out_of_jump_pad) (linux_process_target::wait_1) (linux_process_target::resume_one_lwp_throw) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (linux_process_target::read_pc) (linux_process_target::write_pc) * linux-x86-low.cc (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (x86_target::low_supports_breakpoints): Define. (x86_get_pc): Turn into... (x86_target::low_get_pc): ...this. (x86_set_pc): Turn into... (x86_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (arm_target::low_supports_breakpoints) (arm_target::low_get_pc) (arm_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (bfin_target::low_supports_breakpoints) (bfin_target::low_get_pc) (bfin_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (cris_target::low_supports_breakpoints) (cris_target::low_get_pc) (cris_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (crisv32_target::low_supports_breakpoints) (crisv32_target::low_get_pc) (crisv32_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m32r_target::low_supports_breakpoints) (m32r_target::low_get_pc) (m32r_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m68k_target::low_supports_breakpoints) (m68k_target::low_get_pc) (m68k_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (nios2_target::low_supports_breakpoints) (nios2_target::low_get_pc) (nios2_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (sh_target::low_supports_breakpoints) (sh_target::low_get_pc) (sh_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (xtensa_target::low_supports_breakpoints) (xtensa_target::low_get_pc) (xtensa_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_supports_breakpoints> <low_get_pc>: Declare. (sparc_target::low_supports_breakpoints) (sparc_target::low_get_pc): Define. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tile_target::low_supports_breakpoints) (tile_target::low_get_pc) (tile_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (aarch64_target::low_supports_breakpoints): Define. (aarch64_get_pc): Turn into... (aarch64_target::low_get_pc): ...this. (aarch64_set_pc): Turn into... (aarch64_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (mips_target::low_supports_breakpoints): Define. (mips_get_pc): Turn into... (mips_target::low_get_pc): ...this. (mips_set_pc): Turn into... (mips_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (ppc_target::low_supports_breakpoints): Define. (ppc_get_pc): Turn into... (ppc_target::low_get_pc): ...this. (ppc_set_pc): Turn into... (ppc_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (riscv_target::low_supports_breakpoints): Define. (riscv_get_pc): Turn into... (riscv_target::low_get_pc): ...this. (riscv_set_pc): Turn into... (riscv_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (s390_target::low_supports_breakpoints): Define. (s390_get_pc): Turn into... (s390_target::low_get_pc): ...this. (s390_set_pc): Turn into... (s390_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tic6x_target::low_supports_breakpoints): Define. (tic6x_get_pc): Turn into... (tic6x_target::low_get_pc): ...this. (tic6x_set_pc): Turn into... (tic6x_target::low_set_pc): ...this. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
= (low_supports_breakpoints ()
&& (WSTOPSIG (w) == SIGTRAP
|| ((WSTOPSIG (w) == SIGILL
|| WSTOPSIG (w) == SIGSEGV)
gdbserver/linux-low: turn 'breakpoint_at' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'breakpoint_at' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <low_breakpoint_at>: Declare. Update the callers below: * linux-low.cc (linux_process_target::save_stop_reason) (linux_process_target::thread_still_has_status_pending) (linux_process_target::wait_1) * linux-x86-low.cc (class x86_target) <low_breakpoint_at>: Declare. (x86_breakpoint_at): Turn into... (x86_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <low_breakpoint_at>: Declare. (aarch64_breakpoint_at): Turn into... (aarch64_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (class arm_target) <low_breakpoint_at>: Declare. (arm_target::low_breakpoint_at): Define. (the_low_target): Remove the op field. * linux-bfin-low.cc (class bfin_target) <low_breakpoint_at>: Declare. (bfin_breakpoint_at): Turn into... (bfin_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-cris-low.cc (class cris_target) <low_breakpoint_at>: Declare. (cris_breakpoint_at): Turn into... (cris_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-crisv32-low.cc (class crisv32_target) <low_breakpoint_at>: Declare. (crisv32_breakpoint_at): Turn into... (crisv32_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-ia64-low.cc (class ia64_target) <low_breakpoint_at>: Declare. (ia64_target::low_breakpoint_at): Define. * linux-m32r-low.cc (class m32r_target) <low_breakpoint_at>: Declare. (m32r_breakpoint_at): Turn into... (m32r_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-m68k-low.cc (class m68k_target) <low_breakpoint_at>: Declare. (m68k_breakpoint_at): Turn into... (m68k_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-mips-low.cc (class mips_target) <low_breakpoint_at>: Declare. (mips_breakpoint_at): Turn into... (mips_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-nios2-low.cc (class nios2_target) <low_breakpoint_at>: Declare. (nios2_breakpoint_at): Turn into... (nios2_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (class ppc_target) <low_breakpoint_at>: Declare. (ppc_breakpoint_at): Turn into... (ppc_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-riscv-low.cc (class riscv_target) <low_breakpoint_at>: Declare. (riscv_breakpoint_at): Turn into... (riscv_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-s390-low.cc (class s390_target) <low_breakpoint_at>: Declare. (s390_breakpoint_at): Turn into... (s390_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-sh-low.cc (class sh_target) <low_breakpoint_at>: Declare. (sh_breakpoint_at): Turn into... (sh_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-sparc-low.cc (class sparc_target) <low_breakpoint_at>: Declare. (sparc_breakpoint_at): Turn into... (sparc_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-tic6x-low.cc (class tic6x_target) <low_breakpoint_at>: Declare. (tic6x_breakpoint_at): Turn into... (tic6x_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-tile-low.cc (class tile_target) <low_breakpoint_at>: Declare. (tile_breakpoint_at): Turn into... (tile_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field. * linux-xtensa-low.cc (class xtensa_target) <low_breakpoint_at>: Declare. (xtensa_breakpoint_at): Turn into... (xtensa_target::low_breakpoint_at): ...this. (the_low_target): Remove the op field.
2020-04-02 15:11:26 +02:00
&& low_breakpoint_at (event_child->stop_pc))));
if (maybe_internal_trap)
{
/* Handle anything that requires bookkeeping before deciding to
report the event or continue waiting. */
/* First check if we can explain the SIGTRAP with an internal
breakpoint, or if we should possibly report the event to GDB.
Do this before anything that may remove or insert a
breakpoint. */
bp_explains_trap = breakpoint_inserted_here (event_child->stop_pc);
/* We have a SIGTRAP, possibly a step-over dance has just
finished. If so, tweak the state machine accordingly,
reinsert breakpoints and delete any single-step
breakpoints. */
step_over_finished = finish_step_over (event_child);
/* Now invoke the callbacks of any internal breakpoints there. */
check_breakpoints (event_child->stop_pc);
gdb/gdbserver/ * server.h (LONGEST): New. (struct thread_info) <while_stepping>: New field. (unpack_varlen_hex, xrealloc, pulongest, plongest, phex_nz): Declare. (initialize_tracepoint, handle_tracepoint_general_set) (handle_tracepoint_query, tracepoint_finished_step) (tracepoint_was_hit, release_while_stepping_state_list): (current_traceframe): Declare. * server.c (handle_general_set): Handle tracepoint packets. (read_memory): New. (write_memory): New. (handle_search_memory_1): Use read_memory. (handle_query): Report support for conditional tracepoints, trace state variables, and tracepoint sources. Handle tracepoint queries. (main): Initialize the tracepoints module. (process_serial_event): Handle traceframe reads/writes. * linux-low.c (handle_tracepoints): New. (linux_wait_1): Call it. (linux_resume_one_lwp): Handle while-stepping. (linux_supports_tracepoints, linux_read_pc, linux_write_pc): New. (linux_target_ops): Install them. * linux-low.h (struct linux_target_ops) <supports_tracepoints>: New field. * linux-x86-low.c (x86_supports_tracepoints): New. (the_low_target). Install it. * mem-break.h (delete_breakpoint): Declare. * mem-break.c (delete_breakpoint): Make external. * target.h (struct target_ops): Add `supports_tracepoints', `read_pc', and `write_pc' fields. (target_supports_tracepoints): Define. * utils.c (xrealloc, decimal2str, pulongest, plongest, thirty_two) (phex_nz): New. * regcache.h (struct regcache) <registers_owned>: New field. (init_register_cache, regcache_cpy): Declare. (regcache_read_pc, regcache_write_pc): Declare. (register_cache_size): Declare. (supply_regblock): Declare. * regcache.c (init_register_cache): New. (new_register_cache): Use it. (regcache_cpy): New. (register_cache_size): New. (supply_regblock): New. (regcache_read_pc, regcache_write_pc): New. * tracepoint.c: New. * Makefile.in (OBS): Add tracepoint.o. (tracepoint.o): New rule. gdb/ * regformats/regdat.sh: Include server.h. Don't include regcache.h.
2010-04-09 05:40:00 +02:00
/* Handle tracepoint data collecting. This may overflow the
trace buffer, and cause a tracing stop, removing
breakpoints. */
trace_event = handle_tracepoints (event_child);
if (bp_explains_trap)
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Hit a gdbserver breakpoint.\n");
}
}
else
{
/* We have some other signal, possibly a step-over dance was in
progress, and it should be cancelled too. */
step_over_finished = finish_step_over (event_child);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
}
/* We have all the data we need. Either report the event to GDB, or
resume threads and keep waiting for more. */
/* If we're collecting a fast tracepoint, finish the collection and
move out of the jump pad before delivering a signal. See
linux_stabilize_threads. */
if (WIFSTOPPED (w)
&& WSTOPSIG (w) != SIGTRAP
&& supports_fast_tracepoints ()
&& agent_loaded_p ())
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Got signal %d for LWP %ld. Check if we need "
"to defer or adjust it.\n",
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
WSTOPSIG (w), lwpid_of (current_thread));
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
/* Allow debugging the jump pad itself. */
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
if (current_thread->last_resume_kind != resume_step
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
&& maybe_move_out_of_jump_pad (event_child, &w))
{
enqueue_one_deferred_signal (event_child, &w);
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Signal %d for LWP %ld deferred (in jump pad)\n",
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
WSTOPSIG (w), lwpid_of (current_thread));
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
resume_one_lwp (event_child, 0, 0, NULL);
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
if (debug_threads)
debug_exit ();
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
return ignore_event (ourstatus);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
}
}
gdb/gdbserver/ * server.h (LONGEST): New. (struct thread_info) <while_stepping>: New field. (unpack_varlen_hex, xrealloc, pulongest, plongest, phex_nz): Declare. (initialize_tracepoint, handle_tracepoint_general_set) (handle_tracepoint_query, tracepoint_finished_step) (tracepoint_was_hit, release_while_stepping_state_list): (current_traceframe): Declare. * server.c (handle_general_set): Handle tracepoint packets. (read_memory): New. (write_memory): New. (handle_search_memory_1): Use read_memory. (handle_query): Report support for conditional tracepoints, trace state variables, and tracepoint sources. Handle tracepoint queries. (main): Initialize the tracepoints module. (process_serial_event): Handle traceframe reads/writes. * linux-low.c (handle_tracepoints): New. (linux_wait_1): Call it. (linux_resume_one_lwp): Handle while-stepping. (linux_supports_tracepoints, linux_read_pc, linux_write_pc): New. (linux_target_ops): Install them. * linux-low.h (struct linux_target_ops) <supports_tracepoints>: New field. * linux-x86-low.c (x86_supports_tracepoints): New. (the_low_target). Install it. * mem-break.h (delete_breakpoint): Declare. * mem-break.c (delete_breakpoint): Make external. * target.h (struct target_ops): Add `supports_tracepoints', `read_pc', and `write_pc' fields. (target_supports_tracepoints): Define. * utils.c (xrealloc, decimal2str, pulongest, plongest, thirty_two) (phex_nz): New. * regcache.h (struct regcache) <registers_owned>: New field. (init_register_cache, regcache_cpy): Declare. (regcache_read_pc, regcache_write_pc): Declare. (register_cache_size): Declare. (supply_regblock): Declare. * regcache.c (init_register_cache): New. (new_register_cache): Use it. (regcache_cpy): New. (register_cache_size): New. (supply_regblock): New. (regcache_read_pc, regcache_write_pc): New. * tracepoint.c: New. * Makefile.in (OBS): Add tracepoint.o. (tracepoint.o): New rule. gdb/ * regformats/regdat.sh: Include server.h. Don't include regcache.h.
2010-04-09 05:40:00 +02:00
if (event_child->collecting_fast_tracepoint
!= fast_tpoint_collect_result::not_collecting)
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("LWP %ld was trying to move out of the jump pad (%d). "
"Check if we're already there.\n",
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
lwpid_of (current_thread),
(int) event_child->collecting_fast_tracepoint);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
trace_event = 1;
event_child->collecting_fast_tracepoint
= linux_fast_tracepoint_collecting (event_child, NULL);
if (event_child->collecting_fast_tracepoint
!= fast_tpoint_collect_result::before_insn)
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
{
/* No longer need this breakpoint. */
if (event_child->exit_jump_pad_bkpt != NULL)
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("No longer need exit-jump-pad bkpt; removing it."
"stopping all threads momentarily.\n");
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
/* Other running threads could hit this breakpoint.
We don't handle moribund locations like GDB does,
instead we always pause all threads when removing
breakpoints, so that any step-over or
decr_pc_after_break adjustment is always taken
care of while the breakpoint is still
inserted. */
stop_all_lwps (1, event_child);
delete_breakpoint (event_child->exit_jump_pad_bkpt);
event_child->exit_jump_pad_bkpt = NULL;
unstop_all_lwps (1, event_child);
gdb_assert (event_child->suspended >= 0);
}
}
if (event_child->collecting_fast_tracepoint
== fast_tpoint_collect_result::not_collecting)
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("fast tracepoint finished "
"collecting successfully.\n");
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
/* We may have a deferred signal to report. */
if (dequeue_one_deferred_signal (event_child, &w))
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("dequeued one signal.\n");
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
}
else
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("no deferred signals.\n");
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
if (stabilizing_threads)
{
ourstatus->kind = TARGET_WAITKIND_STOPPED;
gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. gdb/gdbserver/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. include/gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 * gdb/signals.def: Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/arm/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/avr/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/common/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/cr16/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/d10v/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/erc32/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/m32c/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/ppc/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rl78/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rx/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout.
2012-05-24 18:51:47 +02:00
ourstatus->value.sig = GDB_SIGNAL_0;
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
if (debug_threads)
{
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
debug_printf ("wait_1 ret = %s, stopped "
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
"while stabilizing threads\n",
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
target_pid_to_str (ptid_of (current_thread)));
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_exit ();
}
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
return ptid_of (current_thread);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
}
}
}
}
/* Check whether GDB would be interested in this event. */
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
/* Check if GDB is interested in this syscall. */
if (WIFSTOPPED (w)
&& WSTOPSIG (w) == SYSCALL_SIGTRAP
gdbserver/linux-low: turn 'get_syscall_trapinfo' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_syscall_trapinfo' linux target op into a method of process_stratum_target. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <get_syscall_trapinfo> <gdb_catch_this_syscall> <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. * linux-low.cc (get_syscall_trapinfo): Turn into... (linux_process_target::get_syscall_trapinfo): ...this. (linux_process_target::low_get_syscall_trapinfo): Define. (gdb_catch_this_syscall_p): Turn into... (linux_process_target::gdb_catch_this_syscall): ...this. (linux_process_target::low_supports_catch_syscall): Define. Update the callers below. (linux_process_target::wait_1) (linux_process_target::supports_catch_syscall) * linux-x86-low.cc (class x86_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (x86_target::low_supports_catch_syscall): Define. (x86_get_syscall_trapinfo): Turn into... (x86_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (aarch64_target::low_supports_catch_syscall): Define. (aarch64_get_syscall_trapinfo): Turn into... (aarch64_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (class arm_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (arm_target::low_supports_catch_syscall): Define. (arm_get_syscall_trapinfo): Turn into... (arm_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (the_low_target): Remove the op field. * linux-s390-low.cc (the_low_target): Remove the op field.
2020-04-02 15:11:31 +02:00
&& !gdb_catch_this_syscall (event_child))
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
{
if (debug_threads)
{
debug_printf ("Ignored syscall for LWP %ld.\n",
lwpid_of (current_thread));
}
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
resume_one_lwp (event_child, event_child->stepping, 0, NULL);
if (debug_threads)
debug_exit ();
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
return ignore_event (ourstatus);
}
/* If GDB is not interested in this signal, don't stop other
threads, and don't report it to GDB. Just resume the inferior
right away. We do this for threading-related signals as well as
any that GDB specifically requested we ignore. But never ignore
SIGSTOP if we sent it ourselves, and do not ignore signals when
stepping - they may require special handling to skip the signal
2015-02-12 20:55:08 +01:00
handler. Also never ignore signals that could be caused by a
breakpoint. */
if (WIFSTOPPED (w)
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
&& current_thread->last_resume_kind != resume_step
&& (
#if defined (USE_THREAD_DB) && !defined (__ANDROID__)
(current_process ()->priv->thread_db != NULL
&& (WSTOPSIG (w) == __SIGRTMIN
|| WSTOPSIG (w) == __SIGRTMIN + 1))
||
#endif
(cs.pass_signals[gdb_signal_from_host (WSTOPSIG (w))]
&& !(WSTOPSIG (w) == SIGSTOP
2015-02-12 20:55:08 +01:00
&& current_thread->last_resume_kind == resume_stop)
&& !linux_wstatus_maybe_breakpoint (w))))
{
siginfo_t info, *info_p;
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Ignored signal %d for LWP %ld.\n",
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
WSTOPSIG (w), lwpid_of (current_thread));
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
if (ptrace (PTRACE_GETSIGINFO, lwpid_of (current_thread),
(PTRACE_TYPE_ARG3) 0, &info) == 0)
info_p = &info;
else
info_p = NULL;
gdbserver: Fix non-stop / fork / step-over issues Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html This adds a test that has a multithreaded program have several threads continuously fork, while another thread continuously steps over a breakpoint. This exposes several intertwined issues, which this patch addresses: - When we're stopping and suspending threads, some thread may fork, and we missed setting its suspend count to 1, like we do when a new clone/thread is detected. When we next unsuspend threads, the fork child's suspend count goes below 0, which is bogus and fails an assertion. - If a step-over is cancelled because a signal arrives, but then gdb is not interested in the signal, we pass the signal straight back to the inferior. However, we miss that we need to re-increment the suspend counts of all other threads that had been paused for the step-over. As a result, other threads indefinitely end up stuck stopped. - If a detach request comes in just while gdbserver is handling a step-over (in the test at hand, this is GDB detaching the fork child), gdbserver internal errors in stabilize_thread's helpers, which assert that all thread's suspend counts are 0 (otherwise we wouldn't be able to move threads out of the jump pads). The suspend counts aren't 0 while a step-over is in progress, because all threads but the one stepping past the breakpoint must remain paused until the step-over finishes and the breakpoint can be reinserted. - Occasionally, we see "BAD - reinserting but not stepping." being output (from within linux_resume_one_lwp_throw). That was because GDB pokes memory while gdbserver is busy with a step-over, and that suspends threads, and then re-resumes them with proceed_one_lwp, which missed another reason to tell linux_resume_one_lwp that the thread should be set back to stepping. - In a couple places, we were resuming threads that are meant to be suspended. E.g., when a vCont;c/s request for thread B comes in just while gdbserver is stepping thread A past a breakpoint. The resume for thread B must be deferred until the step-over finishes. - The test runs with both "set detach-on-fork" on and off. When off, it exercises the case of GDB detaching the fork child explicitly. When on, it exercises the case of gdb resuming the child explicitly. In the "off" case, gdb seems to exponentially become slower as new inferiors are created. This is _very_ noticeable as with only 100 inferiors gdb is crawling already, which makes the test take quite a bit to run. For that reason, I've disabled the "off" variant for now. gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * target/waitstatus.h (enum target_stop_reason) <TARGET_STOPPED_BY_SINGLE_STEP>: New value. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the fork child's suspend count if stopping and suspending threads. (check_stopped_by_breakpoint): If stopped by trace, set the LWP's stop reason to TARGET_STOPPED_BY_SINGLE_STEP. (linux_detach): Complete an ongoing step-over. (lwp_suspended_inc, lwp_suspended_decr): New functions. Use throughout. (resume_stopped_resumed_lwps): Don't resume a suspended thread. (linux_wait_1): If passing a signal to the inferior after finishing a step-over, unsuspend and re-resume all lwps. If we see a single-step event but the thread should be continuing, don't pass the trap to gdb. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use internal_error instead of gdb_assert. (enqueue_pending_signal): New function. (check_ptrace_stopped_lwp_gone): Add debug output. (start_step_over): Use internal_error instead of gdb_assert. (complete_ongoing_step_over): New function. (linux_resume_one_thread): Don't resume a suspended thread. (proceed_one_lwp): If the LWP is stepping over a breakpoint, reset it stepping. gdb/testsuite/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * gdb.threads/forking-threads-plus-breakpoint.exp: New file. * gdb.threads/forking-threads-plus-breakpoint.c: New file.
2015-08-06 11:30:18 +02:00
if (step_over_finished)
{
/* We cancelled this thread's step-over above. We still
need to unsuspend all other LWPs, and set them back
running again while the signal handler runs. */
unsuspend_all_lwps (event_child);
/* Enqueue the pending signal info so that proceed_all_lwps
doesn't lose it. */
enqueue_pending_signal (event_child, WSTOPSIG (w), info_p);
proceed_all_lwps ();
}
else
{
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
resume_one_lwp (event_child, event_child->stepping,
WSTOPSIG (w), info_p);
gdbserver: Fix non-stop / fork / step-over issues Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html This adds a test that has a multithreaded program have several threads continuously fork, while another thread continuously steps over a breakpoint. This exposes several intertwined issues, which this patch addresses: - When we're stopping and suspending threads, some thread may fork, and we missed setting its suspend count to 1, like we do when a new clone/thread is detected. When we next unsuspend threads, the fork child's suspend count goes below 0, which is bogus and fails an assertion. - If a step-over is cancelled because a signal arrives, but then gdb is not interested in the signal, we pass the signal straight back to the inferior. However, we miss that we need to re-increment the suspend counts of all other threads that had been paused for the step-over. As a result, other threads indefinitely end up stuck stopped. - If a detach request comes in just while gdbserver is handling a step-over (in the test at hand, this is GDB detaching the fork child), gdbserver internal errors in stabilize_thread's helpers, which assert that all thread's suspend counts are 0 (otherwise we wouldn't be able to move threads out of the jump pads). The suspend counts aren't 0 while a step-over is in progress, because all threads but the one stepping past the breakpoint must remain paused until the step-over finishes and the breakpoint can be reinserted. - Occasionally, we see "BAD - reinserting but not stepping." being output (from within linux_resume_one_lwp_throw). That was because GDB pokes memory while gdbserver is busy with a step-over, and that suspends threads, and then re-resumes them with proceed_one_lwp, which missed another reason to tell linux_resume_one_lwp that the thread should be set back to stepping. - In a couple places, we were resuming threads that are meant to be suspended. E.g., when a vCont;c/s request for thread B comes in just while gdbserver is stepping thread A past a breakpoint. The resume for thread B must be deferred until the step-over finishes. - The test runs with both "set detach-on-fork" on and off. When off, it exercises the case of GDB detaching the fork child explicitly. When on, it exercises the case of gdb resuming the child explicitly. In the "off" case, gdb seems to exponentially become slower as new inferiors are created. This is _very_ noticeable as with only 100 inferiors gdb is crawling already, which makes the test take quite a bit to run. For that reason, I've disabled the "off" variant for now. gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * target/waitstatus.h (enum target_stop_reason) <TARGET_STOPPED_BY_SINGLE_STEP>: New value. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the fork child's suspend count if stopping and suspending threads. (check_stopped_by_breakpoint): If stopped by trace, set the LWP's stop reason to TARGET_STOPPED_BY_SINGLE_STEP. (linux_detach): Complete an ongoing step-over. (lwp_suspended_inc, lwp_suspended_decr): New functions. Use throughout. (resume_stopped_resumed_lwps): Don't resume a suspended thread. (linux_wait_1): If passing a signal to the inferior after finishing a step-over, unsuspend and re-resume all lwps. If we see a single-step event but the thread should be continuing, don't pass the trap to gdb. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use internal_error instead of gdb_assert. (enqueue_pending_signal): New function. (check_ptrace_stopped_lwp_gone): Add debug output. (start_step_over): Use internal_error instead of gdb_assert. (complete_ongoing_step_over): New function. (linux_resume_one_thread): Don't resume a suspended thread. (proceed_one_lwp): If the LWP is stepping over a breakpoint, reset it stepping. gdb/testsuite/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * gdb.threads/forking-threads-plus-breakpoint.exp: New file. * gdb.threads/forking-threads-plus-breakpoint.c: New file.
2015-08-06 11:30:18 +02:00
}
if (debug_threads)
debug_exit ();
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
return ignore_event (ourstatus);
}
range stepping: gdbserver (x86 GNU/Linux) This patch adds support for range stepping to GDBserver, teaching it about vCont;r. It'd be easy to enable this for all hardware single-step targets without needing the linux_target_ops hook, however, at least PPC needs special care, due to the fact that PPC atomic sequences can't be hardware single-stepped through, a thing which GDBserver doesn't know about. So this leaves the support limited to x86/x86_64. gdb/ 2013-05-23 Pedro Alves <palves@redhat.com> * NEWS: Mention GDBserver range stepping support. gdb/gdbserver/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * linux-low.c (lwp_in_step_range): New function. (linux_wait_1): If the thread was range stepping and stopped outside the stepping range, report the stop to GDB. Otherwise, continue stepping. Add range stepping debug output. (linux_set_resume_request): Copy the step range from the resume request to the lwp. (linux_supports_range_stepping): New. (linux_target_ops) <supports_range_stepping>: Set to linux_supports_range_stepping. * linux-low.h (struct linux_target_ops) <supports_range_stepping>: New field. (struct lwp_info) <step_range_start, step_range_end>: New fields. * linux-x86-low.c (x86_supports_range_stepping): New. (the_low_target) <supports_range_stepping>: Set to x86_supports_range_stepping. * server.c (handle_v_cont): Handle 'r' action. (handle_v_requests): Append ";r" if the target supports range stepping. * target.h (struct thread_resume) <step_range_start, step_range_end>: New fields. (struct target_ops) <supports_range_stepping>: New field. (target_supports_range_stepping): New macro.
2013-05-23 19:17:50 +02:00
/* Note that all addresses are always "out of the step range" when
there's no range to begin with. */
in_step_range = lwp_in_step_range (event_child);
/* If GDB wanted this thread to single step, and the thread is out
of the step range, we always want to report the SIGTRAP, and let
GDB handle it. Watchpoints should always be reported. So should
signals we can't explain. A SIGTRAP we can't explain could be a
GDB breakpoint --- we may or not support Z0 breakpoints. If we
do, we're be able to handle GDB breakpoints on top of internal
breakpoints, by handling the internal breakpoint and still
reporting the event to GDB. If we don't, we're out of luck, GDB
gdbserver: Fix non-stop / fork / step-over issues Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html This adds a test that has a multithreaded program have several threads continuously fork, while another thread continuously steps over a breakpoint. This exposes several intertwined issues, which this patch addresses: - When we're stopping and suspending threads, some thread may fork, and we missed setting its suspend count to 1, like we do when a new clone/thread is detected. When we next unsuspend threads, the fork child's suspend count goes below 0, which is bogus and fails an assertion. - If a step-over is cancelled because a signal arrives, but then gdb is not interested in the signal, we pass the signal straight back to the inferior. However, we miss that we need to re-increment the suspend counts of all other threads that had been paused for the step-over. As a result, other threads indefinitely end up stuck stopped. - If a detach request comes in just while gdbserver is handling a step-over (in the test at hand, this is GDB detaching the fork child), gdbserver internal errors in stabilize_thread's helpers, which assert that all thread's suspend counts are 0 (otherwise we wouldn't be able to move threads out of the jump pads). The suspend counts aren't 0 while a step-over is in progress, because all threads but the one stepping past the breakpoint must remain paused until the step-over finishes and the breakpoint can be reinserted. - Occasionally, we see "BAD - reinserting but not stepping." being output (from within linux_resume_one_lwp_throw). That was because GDB pokes memory while gdbserver is busy with a step-over, and that suspends threads, and then re-resumes them with proceed_one_lwp, which missed another reason to tell linux_resume_one_lwp that the thread should be set back to stepping. - In a couple places, we were resuming threads that are meant to be suspended. E.g., when a vCont;c/s request for thread B comes in just while gdbserver is stepping thread A past a breakpoint. The resume for thread B must be deferred until the step-over finishes. - The test runs with both "set detach-on-fork" on and off. When off, it exercises the case of GDB detaching the fork child explicitly. When on, it exercises the case of gdb resuming the child explicitly. In the "off" case, gdb seems to exponentially become slower as new inferiors are created. This is _very_ noticeable as with only 100 inferiors gdb is crawling already, which makes the test take quite a bit to run. For that reason, I've disabled the "off" variant for now. gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * target/waitstatus.h (enum target_stop_reason) <TARGET_STOPPED_BY_SINGLE_STEP>: New value. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the fork child's suspend count if stopping and suspending threads. (check_stopped_by_breakpoint): If stopped by trace, set the LWP's stop reason to TARGET_STOPPED_BY_SINGLE_STEP. (linux_detach): Complete an ongoing step-over. (lwp_suspended_inc, lwp_suspended_decr): New functions. Use throughout. (resume_stopped_resumed_lwps): Don't resume a suspended thread. (linux_wait_1): If passing a signal to the inferior after finishing a step-over, unsuspend and re-resume all lwps. If we see a single-step event but the thread should be continuing, don't pass the trap to gdb. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use internal_error instead of gdb_assert. (enqueue_pending_signal): New function. (check_ptrace_stopped_lwp_gone): Add debug output. (start_step_over): Use internal_error instead of gdb_assert. (complete_ongoing_step_over): New function. (linux_resume_one_thread): Don't resume a suspended thread. (proceed_one_lwp): If the LWP is stepping over a breakpoint, reset it stepping. gdb/testsuite/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * gdb.threads/forking-threads-plus-breakpoint.exp: New file. * gdb.threads/forking-threads-plus-breakpoint.c: New file.
2015-08-06 11:30:18 +02:00
won't see the breakpoint hit. If we see a single-step event but
the thread should be continuing, don't pass the trap to gdb.
That indicates that we had previously finished a single-step but
left the single-step pending -- see
complete_ongoing_step_over. */
report_to_gdb = (!maybe_internal_trap
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
|| (current_thread->last_resume_kind == resume_step
range stepping: gdbserver (x86 GNU/Linux) This patch adds support for range stepping to GDBserver, teaching it about vCont;r. It'd be easy to enable this for all hardware single-step targets without needing the linux_target_ops hook, however, at least PPC needs special care, due to the fact that PPC atomic sequences can't be hardware single-stepped through, a thing which GDBserver doesn't know about. So this leaves the support limited to x86/x86_64. gdb/ 2013-05-23 Pedro Alves <palves@redhat.com> * NEWS: Mention GDBserver range stepping support. gdb/gdbserver/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * linux-low.c (lwp_in_step_range): New function. (linux_wait_1): If the thread was range stepping and stopped outside the stepping range, report the stop to GDB. Otherwise, continue stepping. Add range stepping debug output. (linux_set_resume_request): Copy the step range from the resume request to the lwp. (linux_supports_range_stepping): New. (linux_target_ops) <supports_range_stepping>: Set to linux_supports_range_stepping. * linux-low.h (struct linux_target_ops) <supports_range_stepping>: New field. (struct lwp_info) <step_range_start, step_range_end>: New fields. * linux-x86-low.c (x86_supports_range_stepping): New. (the_low_target) <supports_range_stepping>: Set to x86_supports_range_stepping. * server.c (handle_v_cont): Handle 'r' action. (handle_v_requests): Append ";r" if the target supports range stepping. * target.h (struct thread_resume) <step_range_start, step_range_end>: New fields. (struct target_ops) <supports_range_stepping>: New field. (target_supports_range_stepping): New macro.
2013-05-23 19:17:50 +02:00
&& !in_step_range)
|| event_child->stop_reason == TARGET_STOPPED_BY_WATCHPOINT
gdbserver: Fix non-stop / fork / step-over issues Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html This adds a test that has a multithreaded program have several threads continuously fork, while another thread continuously steps over a breakpoint. This exposes several intertwined issues, which this patch addresses: - When we're stopping and suspending threads, some thread may fork, and we missed setting its suspend count to 1, like we do when a new clone/thread is detected. When we next unsuspend threads, the fork child's suspend count goes below 0, which is bogus and fails an assertion. - If a step-over is cancelled because a signal arrives, but then gdb is not interested in the signal, we pass the signal straight back to the inferior. However, we miss that we need to re-increment the suspend counts of all other threads that had been paused for the step-over. As a result, other threads indefinitely end up stuck stopped. - If a detach request comes in just while gdbserver is handling a step-over (in the test at hand, this is GDB detaching the fork child), gdbserver internal errors in stabilize_thread's helpers, which assert that all thread's suspend counts are 0 (otherwise we wouldn't be able to move threads out of the jump pads). The suspend counts aren't 0 while a step-over is in progress, because all threads but the one stepping past the breakpoint must remain paused until the step-over finishes and the breakpoint can be reinserted. - Occasionally, we see "BAD - reinserting but not stepping." being output (from within linux_resume_one_lwp_throw). That was because GDB pokes memory while gdbserver is busy with a step-over, and that suspends threads, and then re-resumes them with proceed_one_lwp, which missed another reason to tell linux_resume_one_lwp that the thread should be set back to stepping. - In a couple places, we were resuming threads that are meant to be suspended. E.g., when a vCont;c/s request for thread B comes in just while gdbserver is stepping thread A past a breakpoint. The resume for thread B must be deferred until the step-over finishes. - The test runs with both "set detach-on-fork" on and off. When off, it exercises the case of GDB detaching the fork child explicitly. When on, it exercises the case of gdb resuming the child explicitly. In the "off" case, gdb seems to exponentially become slower as new inferiors are created. This is _very_ noticeable as with only 100 inferiors gdb is crawling already, which makes the test take quite a bit to run. For that reason, I've disabled the "off" variant for now. gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * target/waitstatus.h (enum target_stop_reason) <TARGET_STOPPED_BY_SINGLE_STEP>: New value. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the fork child's suspend count if stopping and suspending threads. (check_stopped_by_breakpoint): If stopped by trace, set the LWP's stop reason to TARGET_STOPPED_BY_SINGLE_STEP. (linux_detach): Complete an ongoing step-over. (lwp_suspended_inc, lwp_suspended_decr): New functions. Use throughout. (resume_stopped_resumed_lwps): Don't resume a suspended thread. (linux_wait_1): If passing a signal to the inferior after finishing a step-over, unsuspend and re-resume all lwps. If we see a single-step event but the thread should be continuing, don't pass the trap to gdb. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use internal_error instead of gdb_assert. (enqueue_pending_signal): New function. (check_ptrace_stopped_lwp_gone): Add debug output. (start_step_over): Use internal_error instead of gdb_assert. (complete_ongoing_step_over): New function. (linux_resume_one_thread): Don't resume a suspended thread. (proceed_one_lwp): If the LWP is stepping over a breakpoint, reset it stepping. gdb/testsuite/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * gdb.threads/forking-threads-plus-breakpoint.exp: New file. * gdb.threads/forking-threads-plus-breakpoint.c: New file.
2015-08-06 11:30:18 +02:00
|| (!in_step_range
&& !bp_explains_trap
&& !trace_event
&& !step_over_finished
&& !(current_thread->last_resume_kind == resume_continue
&& event_child->stop_reason == TARGET_STOPPED_BY_SINGLE_STEP))
|| (gdb_breakpoint_here (event_child->stop_pc)
Add target-side support for dynamic printf. * NEWS: Mention the additional style. * breakpoint.h (struct bp_target_info): New fields tcommands, persist. (struct bp_location): New field cmd_bytecode. * breakpoint.c: Include format.h. (disconnected_dprintf): New global. (parse_cmd_to_aexpr): New function. (build_target_command_list): New function. (insert_bp_location): Call it. (remove_breakpoints_pid): Skip dprintf breakpoints. (print_one_breakpoint_location): Ditto. (dprintf_style_agent): New global. (dprintf_style_enums): Add dprintf_style_agent. (update_dprintf_command_list): Add agent case. (agent_printf_command): New function. (_initialize_breakpoint): Add new commands. * common/ax.def (printf): New bytecode. * ax.h (ax_string): Declare. * ax-gdb.h (gen_printf): Declare. * ax-gdb.c: Include cli-utils.h, format.h. (gen_printf): New function. (maint_agent_print_command): New function. (_initialize_ax_gdb): Add maint agent-printf command. * ax-general.c (ax_string): New function. (ax_print): Add printf disassembly. * Makefile.in (SFILES): Add format.c (COMMON_OBS): Add format.o. * common/format.h: New file. * common/format.c: New file. * printcmd.c: Include format.h. (ui_printf): Call parse_format_string. * remote.c (remote_state): New field breakpoint_commands. (PACKET_BreakpointCommands): New enum. (remote_breakpoint_commands_feature): New function. (remote_protocol_features): Add new BreakpointCommands entry. (remote_can_run_breakpoint_commands): New function. (remote_add_target_side_commands): New function. (remote_insert_breakpoint): Call it. (remote_insert_hw_breakpoint): Ditto. (_initialize_remote): Add new packet configuration for target-side breakpoint commands. * target.h (struct target_ops): New field to_can_run_breakpoint_commands. (target_can_run_breakpoint_commands): New macro. * target.c (update_current_target): Handle to_can_run_breakpoint_commands. [gdbserver] * Makefile.in (WARN_CFLAGS_NO_FORMAT): Define. (ax.o): Add it to build rule. (ax-ipa.o): Ditto. (OBS): Add format.o. (IPA_OBS): Add format.o. * server.c (handle_query): Claim support for breakpoint commands. (process_point_options): Add command case. (process_serial_event): Leave running if there are printfs in effect. * mem-break.h (any_persistent_commands): Declare. (add_breakpoint_commands): Declare. (gdb_no_commands_at_breakpoint): Declare. (run_breakpoint_commands): Declare. * mem-break.c (struct point_command_list): New struct. (struct breakpoint): New field command_list. (any_persistent_commands): New function. (add_commands_to_breakpoint): New function. (add_breakpoint_commands): New function. (gdb_no_commands_at_breakpoint): New function. (run_breakpoint_commands): New function. * linux-low.c (linux_wait_1): Test for and run breakpoint commands locally. * ax.c: Include format.h. (ax_printf): New function. (gdb_eval_agent_expr): Add printf opcode. [doc] * gdb.texinfo (Dynamic Printf): Mention agent style and disconnected dprintf. (Maintenance Commands): Describe maint agent-printf. (General Query Packets): Mention BreakpointCommands feature. (Packets): Document commands extension to Z0 packet. * agentexpr.texi (Bytecode Descriptions): Document printf bytecode. [testsuite] * gdb.base/dprintf.exp: Add agent style tests.
2012-07-02 17:29:39 +02:00
&& gdb_condition_true_at_breakpoint (event_child->stop_pc)
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
&& gdb_no_commands_at_breakpoint (event_child->stop_pc))
Linux gdbserver confused when event randomization picks process exit event The tail end of linux_wait_1 isn't expecting that the select_event_lwp machinery can pick a whole-process exit event to report to GDB. When that happens, both gdb and gdbserver end up quite confused: ... (gdb) [Thread 24971.24971] #1 stopped. 0x0000003615a011f0 in ?? () c& Continuing. (gdb) [New Thread 24971.24981] [New Thread 24983.24983] [New Thread 24971.24982] [Thread 24983.24983] #3 stopped. 0x0000003615ebc7cc in __libc_fork () at ../nptl/sysdeps/unix/sysv/linux/fork.c:130 130 pid = ARCH_FORK (); [New Thread 24984.24984] Error in re-setting breakpoint -16: PC register is not available Error in re-setting breakpoint -17: PC register is not available Error in re-setting breakpoint -18: PC register is not available Error in re-setting breakpoint -19: PC register is not available Error in re-setting breakpoint -24: PC register is not available Error in re-setting breakpoint -25: PC register is not available Error in re-setting breakpoint -26: PC register is not available Error in re-setting breakpoint -27: PC register is not available Error in re-setting breakpoint -28: PC register is not available Error in re-setting breakpoint -29: PC register is not available Error in re-setting breakpoint -30: PC register is not available PC register is not available (gdb) gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (add_lwp): Set waitstatus to TARGET_WAITKIND_IGNORE. (linux_thread_alive): Use lwp_is_marked_dead. (extended_event_reported): Delete. (linux_wait_1): Check if waitstatus is TARGET_WAITKIND_IGNORE instead of extended_event_reported. (mark_lwp_dead): Don't set the 'dead' flag. Store the waitstatus as well. (lwp_is_marked_dead): New function. (lwp_running): Use lwp_is_marked_dead. * linux-low.h: Delete 'dead' field, and update 'waitstatus's comment.
2015-08-06 11:30:17 +02:00
|| event_child->waitstatus.kind != TARGET_WAITKIND_IGNORE);
Add target-side support for dynamic printf. * NEWS: Mention the additional style. * breakpoint.h (struct bp_target_info): New fields tcommands, persist. (struct bp_location): New field cmd_bytecode. * breakpoint.c: Include format.h. (disconnected_dprintf): New global. (parse_cmd_to_aexpr): New function. (build_target_command_list): New function. (insert_bp_location): Call it. (remove_breakpoints_pid): Skip dprintf breakpoints. (print_one_breakpoint_location): Ditto. (dprintf_style_agent): New global. (dprintf_style_enums): Add dprintf_style_agent. (update_dprintf_command_list): Add agent case. (agent_printf_command): New function. (_initialize_breakpoint): Add new commands. * common/ax.def (printf): New bytecode. * ax.h (ax_string): Declare. * ax-gdb.h (gen_printf): Declare. * ax-gdb.c: Include cli-utils.h, format.h. (gen_printf): New function. (maint_agent_print_command): New function. (_initialize_ax_gdb): Add maint agent-printf command. * ax-general.c (ax_string): New function. (ax_print): Add printf disassembly. * Makefile.in (SFILES): Add format.c (COMMON_OBS): Add format.o. * common/format.h: New file. * common/format.c: New file. * printcmd.c: Include format.h. (ui_printf): Call parse_format_string. * remote.c (remote_state): New field breakpoint_commands. (PACKET_BreakpointCommands): New enum. (remote_breakpoint_commands_feature): New function. (remote_protocol_features): Add new BreakpointCommands entry. (remote_can_run_breakpoint_commands): New function. (remote_add_target_side_commands): New function. (remote_insert_breakpoint): Call it. (remote_insert_hw_breakpoint): Ditto. (_initialize_remote): Add new packet configuration for target-side breakpoint commands. * target.h (struct target_ops): New field to_can_run_breakpoint_commands. (target_can_run_breakpoint_commands): New macro. * target.c (update_current_target): Handle to_can_run_breakpoint_commands. [gdbserver] * Makefile.in (WARN_CFLAGS_NO_FORMAT): Define. (ax.o): Add it to build rule. (ax-ipa.o): Ditto. (OBS): Add format.o. (IPA_OBS): Add format.o. * server.c (handle_query): Claim support for breakpoint commands. (process_point_options): Add command case. (process_serial_event): Leave running if there are printfs in effect. * mem-break.h (any_persistent_commands): Declare. (add_breakpoint_commands): Declare. (gdb_no_commands_at_breakpoint): Declare. (run_breakpoint_commands): Declare. * mem-break.c (struct point_command_list): New struct. (struct breakpoint): New field command_list. (any_persistent_commands): New function. (add_commands_to_breakpoint): New function. (add_breakpoint_commands): New function. (gdb_no_commands_at_breakpoint): New function. (run_breakpoint_commands): New function. * linux-low.c (linux_wait_1): Test for and run breakpoint commands locally. * ax.c: Include format.h. (ax_printf): New function. (gdb_eval_agent_expr): Add printf opcode. [doc] * gdb.texinfo (Dynamic Printf): Mention agent style and disconnected dprintf. (Maintenance Commands): Describe maint agent-printf. (General Query Packets): Mention BreakpointCommands feature. (Packets): Document commands extension to Z0 packet. * agentexpr.texi (Bytecode Descriptions): Document printf bytecode. [testsuite] * gdb.base/dprintf.exp: Add agent style tests.
2012-07-02 17:29:39 +02:00
run_breakpoint_commands (event_child->stop_pc);
/* We found no reason GDB would want us to stop. We either hit one
of our own breakpoints, or finished an internal step GDB
shouldn't know about. */
if (!report_to_gdb)
{
if (debug_threads)
{
if (bp_explains_trap)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Hit a gdbserver breakpoint.\n");
if (step_over_finished)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Step-over finished.\n");
gdb/gdbserver/ * server.h (LONGEST): New. (struct thread_info) <while_stepping>: New field. (unpack_varlen_hex, xrealloc, pulongest, plongest, phex_nz): Declare. (initialize_tracepoint, handle_tracepoint_general_set) (handle_tracepoint_query, tracepoint_finished_step) (tracepoint_was_hit, release_while_stepping_state_list): (current_traceframe): Declare. * server.c (handle_general_set): Handle tracepoint packets. (read_memory): New. (write_memory): New. (handle_search_memory_1): Use read_memory. (handle_query): Report support for conditional tracepoints, trace state variables, and tracepoint sources. Handle tracepoint queries. (main): Initialize the tracepoints module. (process_serial_event): Handle traceframe reads/writes. * linux-low.c (handle_tracepoints): New. (linux_wait_1): Call it. (linux_resume_one_lwp): Handle while-stepping. (linux_supports_tracepoints, linux_read_pc, linux_write_pc): New. (linux_target_ops): Install them. * linux-low.h (struct linux_target_ops) <supports_tracepoints>: New field. * linux-x86-low.c (x86_supports_tracepoints): New. (the_low_target). Install it. * mem-break.h (delete_breakpoint): Declare. * mem-break.c (delete_breakpoint): Make external. * target.h (struct target_ops): Add `supports_tracepoints', `read_pc', and `write_pc' fields. (target_supports_tracepoints): Define. * utils.c (xrealloc, decimal2str, pulongest, plongest, thirty_two) (phex_nz): New. * regcache.h (struct regcache) <registers_owned>: New field. (init_register_cache, regcache_cpy): Declare. (regcache_read_pc, regcache_write_pc): Declare. (register_cache_size): Declare. (supply_regblock): Declare. * regcache.c (init_register_cache): New. (new_register_cache): Use it. (regcache_cpy): New. (register_cache_size): New. (supply_regblock): New. (regcache_read_pc, regcache_write_pc): New. * tracepoint.c: New. * Makefile.in (OBS): Add tracepoint.o. (tracepoint.o): New rule. gdb/ * regformats/regdat.sh: Include server.h. Don't include regcache.h.
2010-04-09 05:40:00 +02:00
if (trace_event)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Tracepoint event.\n");
range stepping: gdbserver (x86 GNU/Linux) This patch adds support for range stepping to GDBserver, teaching it about vCont;r. It'd be easy to enable this for all hardware single-step targets without needing the linux_target_ops hook, however, at least PPC needs special care, due to the fact that PPC atomic sequences can't be hardware single-stepped through, a thing which GDBserver doesn't know about. So this leaves the support limited to x86/x86_64. gdb/ 2013-05-23 Pedro Alves <palves@redhat.com> * NEWS: Mention GDBserver range stepping support. gdb/gdbserver/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * linux-low.c (lwp_in_step_range): New function. (linux_wait_1): If the thread was range stepping and stopped outside the stepping range, report the stop to GDB. Otherwise, continue stepping. Add range stepping debug output. (linux_set_resume_request): Copy the step range from the resume request to the lwp. (linux_supports_range_stepping): New. (linux_target_ops) <supports_range_stepping>: Set to linux_supports_range_stepping. * linux-low.h (struct linux_target_ops) <supports_range_stepping>: New field. (struct lwp_info) <step_range_start, step_range_end>: New fields. * linux-x86-low.c (x86_supports_range_stepping): New. (the_low_target) <supports_range_stepping>: Set to x86_supports_range_stepping. * server.c (handle_v_cont): Handle 'r' action. (handle_v_requests): Append ";r" if the target supports range stepping. * target.h (struct thread_resume) <step_range_start, step_range_end>: New fields. (struct target_ops) <supports_range_stepping>: New field. (target_supports_range_stepping): New macro.
2013-05-23 19:17:50 +02:00
if (lwp_in_step_range (event_child))
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Range stepping pc 0x%s [0x%s, 0x%s).\n",
paddress (event_child->stop_pc),
paddress (event_child->step_range_start),
paddress (event_child->step_range_end));
}
/* We're not reporting this breakpoint to GDB, so apply the
decr_pc_after_break adjustment to the inferior's regcache
ourselves. */
gdbserver/linux-low: turn 'get_pc' and 'set_pc' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_pc' and 'set_pc' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. * linux-low.cc (supports_breakpoints): Turn into... (linux_process_target::low_supports_breakpoints): ...this. (linux_process_target::low_get_pc): Define. (linux_process_target::low_set_pc): Define. Update the callers below. (linux_process_target::get_pc) (linux_process_target::save_stop_reason) (linux_process_target::maybe_move_out_of_jump_pad) (linux_process_target::wait_1) (linux_process_target::resume_one_lwp_throw) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (linux_process_target::read_pc) (linux_process_target::write_pc) * linux-x86-low.cc (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (x86_target::low_supports_breakpoints): Define. (x86_get_pc): Turn into... (x86_target::low_get_pc): ...this. (x86_set_pc): Turn into... (x86_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (arm_target::low_supports_breakpoints) (arm_target::low_get_pc) (arm_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (bfin_target::low_supports_breakpoints) (bfin_target::low_get_pc) (bfin_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (cris_target::low_supports_breakpoints) (cris_target::low_get_pc) (cris_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (crisv32_target::low_supports_breakpoints) (crisv32_target::low_get_pc) (crisv32_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m32r_target::low_supports_breakpoints) (m32r_target::low_get_pc) (m32r_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m68k_target::low_supports_breakpoints) (m68k_target::low_get_pc) (m68k_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (nios2_target::low_supports_breakpoints) (nios2_target::low_get_pc) (nios2_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (sh_target::low_supports_breakpoints) (sh_target::low_get_pc) (sh_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (xtensa_target::low_supports_breakpoints) (xtensa_target::low_get_pc) (xtensa_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_supports_breakpoints> <low_get_pc>: Declare. (sparc_target::low_supports_breakpoints) (sparc_target::low_get_pc): Define. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tile_target::low_supports_breakpoints) (tile_target::low_get_pc) (tile_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (aarch64_target::low_supports_breakpoints): Define. (aarch64_get_pc): Turn into... (aarch64_target::low_get_pc): ...this. (aarch64_set_pc): Turn into... (aarch64_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (mips_target::low_supports_breakpoints): Define. (mips_get_pc): Turn into... (mips_target::low_get_pc): ...this. (mips_set_pc): Turn into... (mips_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (ppc_target::low_supports_breakpoints): Define. (ppc_get_pc): Turn into... (ppc_target::low_get_pc): ...this. (ppc_set_pc): Turn into... (ppc_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (riscv_target::low_supports_breakpoints): Define. (riscv_get_pc): Turn into... (riscv_target::low_get_pc): ...this. (riscv_set_pc): Turn into... (riscv_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (s390_target::low_supports_breakpoints): Define. (s390_get_pc): Turn into... (s390_target::low_get_pc): ...this. (s390_set_pc): Turn into... (s390_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tic6x_target::low_supports_breakpoints): Define. (tic6x_get_pc): Turn into... (tic6x_target::low_get_pc): ...this. (tic6x_set_pc): Turn into... (tic6x_target::low_set_pc): ...this. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
if (low_supports_breakpoints ())
{
struct regcache *regcache
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
= get_thread_regcache (current_thread, 1);
gdbserver/linux-low: turn 'get_pc' and 'set_pc' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_pc' and 'set_pc' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. * linux-low.cc (supports_breakpoints): Turn into... (linux_process_target::low_supports_breakpoints): ...this. (linux_process_target::low_get_pc): Define. (linux_process_target::low_set_pc): Define. Update the callers below. (linux_process_target::get_pc) (linux_process_target::save_stop_reason) (linux_process_target::maybe_move_out_of_jump_pad) (linux_process_target::wait_1) (linux_process_target::resume_one_lwp_throw) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (linux_process_target::read_pc) (linux_process_target::write_pc) * linux-x86-low.cc (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (x86_target::low_supports_breakpoints): Define. (x86_get_pc): Turn into... (x86_target::low_get_pc): ...this. (x86_set_pc): Turn into... (x86_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (arm_target::low_supports_breakpoints) (arm_target::low_get_pc) (arm_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (bfin_target::low_supports_breakpoints) (bfin_target::low_get_pc) (bfin_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (cris_target::low_supports_breakpoints) (cris_target::low_get_pc) (cris_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (crisv32_target::low_supports_breakpoints) (crisv32_target::low_get_pc) (crisv32_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m32r_target::low_supports_breakpoints) (m32r_target::low_get_pc) (m32r_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m68k_target::low_supports_breakpoints) (m68k_target::low_get_pc) (m68k_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (nios2_target::low_supports_breakpoints) (nios2_target::low_get_pc) (nios2_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (sh_target::low_supports_breakpoints) (sh_target::low_get_pc) (sh_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (xtensa_target::low_supports_breakpoints) (xtensa_target::low_get_pc) (xtensa_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_supports_breakpoints> <low_get_pc>: Declare. (sparc_target::low_supports_breakpoints) (sparc_target::low_get_pc): Define. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tile_target::low_supports_breakpoints) (tile_target::low_get_pc) (tile_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (aarch64_target::low_supports_breakpoints): Define. (aarch64_get_pc): Turn into... (aarch64_target::low_get_pc): ...this. (aarch64_set_pc): Turn into... (aarch64_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (mips_target::low_supports_breakpoints): Define. (mips_get_pc): Turn into... (mips_target::low_get_pc): ...this. (mips_set_pc): Turn into... (mips_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (ppc_target::low_supports_breakpoints): Define. (ppc_get_pc): Turn into... (ppc_target::low_get_pc): ...this. (ppc_set_pc): Turn into... (ppc_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (riscv_target::low_supports_breakpoints): Define. (riscv_get_pc): Turn into... (riscv_target::low_get_pc): ...this. (riscv_set_pc): Turn into... (riscv_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (s390_target::low_supports_breakpoints): Define. (s390_get_pc): Turn into... (s390_target::low_get_pc): ...this. (s390_set_pc): Turn into... (s390_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tic6x_target::low_supports_breakpoints): Define. (tic6x_get_pc): Turn into... (tic6x_target::low_get_pc): ...this. (tic6x_set_pc): Turn into... (tic6x_target::low_set_pc): ...this. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
low_set_pc (regcache, event_child->stop_pc);
}
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
if (step_over_finished)
{
/* If we have finished stepping over a breakpoint, we've
stopped and suspended all LWPs momentarily except the
stepping one. This is where we resume them all again.
We're going to keep waiting, so use proceed, which
handles stepping over the next breakpoint. */
unsuspend_all_lwps (event_child);
}
else
{
/* Remove the single-step breakpoints if any. Note that
there isn't single-step breakpoint if we finished stepping
over. */
gdbserver/linux-low: turn 'supports_software_single_step' and 'get_next_pcs' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Remove the 'supports_software_single_step' linux target op and let the concrete linux target define it by overriding the op in process_stratum_target. Turn the 'get_next_pcs' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <supports_software_single_step>: Remove. <low_get_next_pcs>: Declare. * linux-low.cc (can_software_single_step): Remove. (linux_process_target::low_get_next_pcs): Define. (linux_process_target::supports_software_single_step): Remove. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::wait_1) (linux_process_target::install_software_single_step_breakpoints) (linux_process_target::single_step) (linux_process_target::thread_needs_step_over) (linux_process_target::proceed_one_lwp) (linux_process_target::supports_range_stepping) * linux-x86-low.cc (the_low_target): Remove the op field. * linux-aarch64-low.cc (the_low_target): Ditto. * linux-bfin-low.cc (the_low_target): Ditto. * linux-cris-low.cc (the_low_target): Ditto. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-mips-low.cc (the_low_target): Ditto. * linux-nios2-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-riscv-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-sparc-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto. * linux-arm-low.cc (class arm_target) <low_get_next_pcs> <supports_software_single_step>: Declare. (arm_target::supports_software_single_step): Define. (arm_gdbserver_get_next_pcs): Turn into... (arm_target::low_get_next_pcs): ...this. (the_low_target): Remove the op field.
2020-04-02 15:11:26 +02:00
if (supports_software_single_step ()
&& has_single_step_breakpoints (current_thread))
{
stop_all_lwps (0, event_child);
delete_single_step_breakpoints (current_thread);
unstop_all_lwps (0, event_child);
}
}
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
if (debug_threads)
debug_printf ("proceeding all threads.\n");
proceed_all_lwps ();
if (debug_threads)
debug_exit ();
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
return ignore_event (ourstatus);
}
if (debug_threads)
{
Linux gdbserver confused when event randomization picks process exit event The tail end of linux_wait_1 isn't expecting that the select_event_lwp machinery can pick a whole-process exit event to report to GDB. When that happens, both gdb and gdbserver end up quite confused: ... (gdb) [Thread 24971.24971] #1 stopped. 0x0000003615a011f0 in ?? () c& Continuing. (gdb) [New Thread 24971.24981] [New Thread 24983.24983] [New Thread 24971.24982] [Thread 24983.24983] #3 stopped. 0x0000003615ebc7cc in __libc_fork () at ../nptl/sysdeps/unix/sysv/linux/fork.c:130 130 pid = ARCH_FORK (); [New Thread 24984.24984] Error in re-setting breakpoint -16: PC register is not available Error in re-setting breakpoint -17: PC register is not available Error in re-setting breakpoint -18: PC register is not available Error in re-setting breakpoint -19: PC register is not available Error in re-setting breakpoint -24: PC register is not available Error in re-setting breakpoint -25: PC register is not available Error in re-setting breakpoint -26: PC register is not available Error in re-setting breakpoint -27: PC register is not available Error in re-setting breakpoint -28: PC register is not available Error in re-setting breakpoint -29: PC register is not available Error in re-setting breakpoint -30: PC register is not available PC register is not available (gdb) gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (add_lwp): Set waitstatus to TARGET_WAITKIND_IGNORE. (linux_thread_alive): Use lwp_is_marked_dead. (extended_event_reported): Delete. (linux_wait_1): Check if waitstatus is TARGET_WAITKIND_IGNORE instead of extended_event_reported. (mark_lwp_dead): Don't set the 'dead' flag. Store the waitstatus as well. (lwp_is_marked_dead): New function. (lwp_running): Use lwp_is_marked_dead. * linux-low.h: Delete 'dead' field, and update 'waitstatus's comment.
2015-08-06 11:30:17 +02:00
if (event_child->waitstatus.kind != TARGET_WAITKIND_IGNORE)
{
std::string str
= target_waitstatus_to_string (&event_child->waitstatus);
debug_printf ("LWP %ld: extended event with waitstatus %s\n",
lwpid_of (get_lwp_thread (event_child)), str.c_str ());
}
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
if (current_thread->last_resume_kind == resume_step)
range stepping: gdbserver (x86 GNU/Linux) This patch adds support for range stepping to GDBserver, teaching it about vCont;r. It'd be easy to enable this for all hardware single-step targets without needing the linux_target_ops hook, however, at least PPC needs special care, due to the fact that PPC atomic sequences can't be hardware single-stepped through, a thing which GDBserver doesn't know about. So this leaves the support limited to x86/x86_64. gdb/ 2013-05-23 Pedro Alves <palves@redhat.com> * NEWS: Mention GDBserver range stepping support. gdb/gdbserver/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * linux-low.c (lwp_in_step_range): New function. (linux_wait_1): If the thread was range stepping and stopped outside the stepping range, report the stop to GDB. Otherwise, continue stepping. Add range stepping debug output. (linux_set_resume_request): Copy the step range from the resume request to the lwp. (linux_supports_range_stepping): New. (linux_target_ops) <supports_range_stepping>: Set to linux_supports_range_stepping. * linux-low.h (struct linux_target_ops) <supports_range_stepping>: New field. (struct lwp_info) <step_range_start, step_range_end>: New fields. * linux-x86-low.c (x86_supports_range_stepping): New. (the_low_target) <supports_range_stepping>: Set to x86_supports_range_stepping. * server.c (handle_v_cont): Handle 'r' action. (handle_v_requests): Append ";r" if the target supports range stepping. * target.h (struct thread_resume) <step_range_start, step_range_end>: New fields. (struct target_ops) <supports_range_stepping>: New field. (target_supports_range_stepping): New macro.
2013-05-23 19:17:50 +02:00
{
if (event_child->step_range_start == event_child->step_range_end)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("GDB wanted to single-step, reporting event.\n");
range stepping: gdbserver (x86 GNU/Linux) This patch adds support for range stepping to GDBserver, teaching it about vCont;r. It'd be easy to enable this for all hardware single-step targets without needing the linux_target_ops hook, however, at least PPC needs special care, due to the fact that PPC atomic sequences can't be hardware single-stepped through, a thing which GDBserver doesn't know about. So this leaves the support limited to x86/x86_64. gdb/ 2013-05-23 Pedro Alves <palves@redhat.com> * NEWS: Mention GDBserver range stepping support. gdb/gdbserver/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * linux-low.c (lwp_in_step_range): New function. (linux_wait_1): If the thread was range stepping and stopped outside the stepping range, report the stop to GDB. Otherwise, continue stepping. Add range stepping debug output. (linux_set_resume_request): Copy the step range from the resume request to the lwp. (linux_supports_range_stepping): New. (linux_target_ops) <supports_range_stepping>: Set to linux_supports_range_stepping. * linux-low.h (struct linux_target_ops) <supports_range_stepping>: New field. (struct lwp_info) <step_range_start, step_range_end>: New fields. * linux-x86-low.c (x86_supports_range_stepping): New. (the_low_target) <supports_range_stepping>: Set to x86_supports_range_stepping. * server.c (handle_v_cont): Handle 'r' action. (handle_v_requests): Append ";r" if the target supports range stepping. * target.h (struct thread_resume) <step_range_start, step_range_end>: New fields. (struct target_ops) <supports_range_stepping>: New field. (target_supports_range_stepping): New macro.
2013-05-23 19:17:50 +02:00
else if (!lwp_in_step_range (event_child))
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Out of step range, reporting event.\n");
range stepping: gdbserver (x86 GNU/Linux) This patch adds support for range stepping to GDBserver, teaching it about vCont;r. It'd be easy to enable this for all hardware single-step targets without needing the linux_target_ops hook, however, at least PPC needs special care, due to the fact that PPC atomic sequences can't be hardware single-stepped through, a thing which GDBserver doesn't know about. So this leaves the support limited to x86/x86_64. gdb/ 2013-05-23 Pedro Alves <palves@redhat.com> * NEWS: Mention GDBserver range stepping support. gdb/gdbserver/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * linux-low.c (lwp_in_step_range): New function. (linux_wait_1): If the thread was range stepping and stopped outside the stepping range, report the stop to GDB. Otherwise, continue stepping. Add range stepping debug output. (linux_set_resume_request): Copy the step range from the resume request to the lwp. (linux_supports_range_stepping): New. (linux_target_ops) <supports_range_stepping>: Set to linux_supports_range_stepping. * linux-low.h (struct linux_target_ops) <supports_range_stepping>: New field. (struct lwp_info) <step_range_start, step_range_end>: New fields. * linux-x86-low.c (x86_supports_range_stepping): New. (the_low_target) <supports_range_stepping>: Set to x86_supports_range_stepping. * server.c (handle_v_cont): Handle 'r' action. (handle_v_requests): Append ";r" if the target supports range stepping. * target.h (struct thread_resume) <step_range_start, step_range_end>: New fields. (struct target_ops) <supports_range_stepping>: New field. (target_supports_range_stepping): New macro.
2013-05-23 19:17:50 +02:00
}
if (event_child->stop_reason == TARGET_STOPPED_BY_WATCHPOINT)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Stopped by watchpoint.\n");
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
else if (gdb_breakpoint_here (event_child->stop_pc))
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Stopped by GDB breakpoint.\n");
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Hit a non-gdbserver trap event.\n");
}
/* Alright, we're going to report a stop. */
/* Remove single-step breakpoints. */
gdbserver/linux-low: turn 'supports_software_single_step' and 'get_next_pcs' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Remove the 'supports_software_single_step' linux target op and let the concrete linux target define it by overriding the op in process_stratum_target. Turn the 'get_next_pcs' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <supports_software_single_step>: Remove. <low_get_next_pcs>: Declare. * linux-low.cc (can_software_single_step): Remove. (linux_process_target::low_get_next_pcs): Define. (linux_process_target::supports_software_single_step): Remove. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::wait_1) (linux_process_target::install_software_single_step_breakpoints) (linux_process_target::single_step) (linux_process_target::thread_needs_step_over) (linux_process_target::proceed_one_lwp) (linux_process_target::supports_range_stepping) * linux-x86-low.cc (the_low_target): Remove the op field. * linux-aarch64-low.cc (the_low_target): Ditto. * linux-bfin-low.cc (the_low_target): Ditto. * linux-cris-low.cc (the_low_target): Ditto. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-mips-low.cc (the_low_target): Ditto. * linux-nios2-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-riscv-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-sparc-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto. * linux-arm-low.cc (class arm_target) <low_get_next_pcs> <supports_software_single_step>: Declare. (arm_target::supports_software_single_step): Define. (arm_gdbserver_get_next_pcs): Turn into... (arm_target::low_get_next_pcs): ...this. (the_low_target): Remove the op field.
2020-04-02 15:11:26 +02:00
if (supports_software_single_step ())
{
/* Remove single-step breakpoints or not. It it is true, stop all
lwps, so that other threads won't hit the breakpoint in the
staled memory. */
int remove_single_step_breakpoints_p = 0;
if (non_stop)
{
remove_single_step_breakpoints_p
= has_single_step_breakpoints (current_thread);
}
else
{
/* In all-stop, a stop reply cancels all previous resume
requests. Delete all single-step breakpoints. */
gdbserver: use std::list for all_threads Remove the usage of inferior_list for the all_threads list in gdbserver. The entry field in thread_info is removed, and replaced by a simple ptid field. I added some functions to iterate (for_each_thread) and find threads (find_thread). However, changing all the users of find_inferior & co to use these new functions would have made the patch way too big. So I opted instead to make find_inferior & co some shims, so that the existing code only needs to be updated minimally. We can then update the existing code to use the new functions incrementally (I've started to do the work, but I'll post it afterwards, see [1] if you want a peek). This patch has been built-tested on all relevant platforms, except lynx. I also regtested using the native-gdbserver and native-extended-gdbserver boards on x86. [1] https://github.com/simark/binutils-gdb/commits/kill-inferior-list-entry gdb/gdbserver/ChangeLog: * inferiors.h: (struct inferior_list): Remove. (struct inferior_list_entry); Remove. (add_inferior_to_list, clear_inferior_list, one_inferior_p, A_I_NEXT, ALL_INFERIORS_TYPE, ALL_INFERIORS, remove_inferior, get_first_inferior): Remove. (for_each_inferior, for_each_inferior_with_data, find_inferior, find_inferior_id, find_inferior_in_random): Change signature. * inferiors.c (all_threads): Change type to std::list<thread_info *>. (get_thread): Remove macro. (find_inferior, find_inferior_id): Change signature, implement using find_thread. (find_inferior_in_random): Change signature, implement using find_thread_in_random. (for_each_inferior, for_each_inferior_with_data): Change signature, implement using for_each_thread. (add_inferior_to_list, remove_inferior): Remove. (add_thread, get_first_thread, thread_of_pid, find_any_thread_of_pid, free_one_thread, remove_thread): Update. (get_first_inferior, one_inferior_p, clear_inferior_list): Remove. (clear_inferiors, get_thread_process): Update. * gdbthread.h: Include <list>. (struct thread_info) <entry>: Remove field. <id>: New field. (all_threads): Change type to std::list<thread_info *>. (get_first_inferior): Add doc. (find_thread, for_each_thread, find_thread_in_random): New functions. (current_ptid, pid_of, ptid_of, lwpid_of): Update. * linux-arm-low.c (update_registers_callback): Update. * linux-low.c (second_thread_of_pid_p): Update. (kill_one_lwp_callback, linux_detach_lwp_callback, delete_lwp_callback, status_pending_p_callback, same_lwp, find_lwp_pid, num_lwps, iterate_over_lwps_filter, iterate_over_lwps, not_stopped_callback, resume_stopped_resumed_lwps, count_events_callback, select_singlestep_lwp_callback, select_event_lwp_callback, unsuspend_one_lwp, linux_wait_1, send_sigstop_callback, suspend_and_send_sigstop_callback, wait_for_sigstop, stuck_in_jump_pad_callback, move_out_of_jump_pad_callback, lwp_running, linux_set_resume_request, resume_status_pending_p, need_step_over_p, start_step_over, linux_resume_one_thread, proceed_one_lwp, unsuspend_and_proceed_one_lwp, reset_lwp_ptrace_options_callback): Update. * linux-mips-low.c (update_watch_registers_callback): Update. * regcache.c (regcache_invalidate_one, regcache_invalidate): Update. (free_register_cache_thread_one): Remove. (regcache_release): Update. * server.c (handle_btrace_enable_bts, handle_btrace_enable_pt, handle_qxfer_threads_worker): Update. (handle_query): Update, use list iterator. (visit_actioned_threads, handle_pending_status, queue_stop_reply_callback, gdb_wants_all_threads_stopped, clear_pending_status_callback, set_pending_status_callback, find_status_pending_thread_callback, handle_status, process_serial_event): Update. * target.c (thread_search_callback): Update. * thread-db.c (thread_db_get_tls_address): Update. * tracepoint.c (tracepoint_finished_step, tracepoint_was_hit): Update. * win32-i386-low.c (update_debug_registers_callback): Update. * win32-low.c (delete_thread_info, child_delete_thread, continue_one_thread, suspend_one_thread, get_child_debug_event): Adjust.
2017-10-14 15:11:12 +02:00
find_thread ([&] (thread_info *thread) {
if (has_single_step_breakpoints (thread))
{
remove_single_step_breakpoints_p = 1;
return true;
}
gdbserver: use std::list for all_threads Remove the usage of inferior_list for the all_threads list in gdbserver. The entry field in thread_info is removed, and replaced by a simple ptid field. I added some functions to iterate (for_each_thread) and find threads (find_thread). However, changing all the users of find_inferior & co to use these new functions would have made the patch way too big. So I opted instead to make find_inferior & co some shims, so that the existing code only needs to be updated minimally. We can then update the existing code to use the new functions incrementally (I've started to do the work, but I'll post it afterwards, see [1] if you want a peek). This patch has been built-tested on all relevant platforms, except lynx. I also regtested using the native-gdbserver and native-extended-gdbserver boards on x86. [1] https://github.com/simark/binutils-gdb/commits/kill-inferior-list-entry gdb/gdbserver/ChangeLog: * inferiors.h: (struct inferior_list): Remove. (struct inferior_list_entry); Remove. (add_inferior_to_list, clear_inferior_list, one_inferior_p, A_I_NEXT, ALL_INFERIORS_TYPE, ALL_INFERIORS, remove_inferior, get_first_inferior): Remove. (for_each_inferior, for_each_inferior_with_data, find_inferior, find_inferior_id, find_inferior_in_random): Change signature. * inferiors.c (all_threads): Change type to std::list<thread_info *>. (get_thread): Remove macro. (find_inferior, find_inferior_id): Change signature, implement using find_thread. (find_inferior_in_random): Change signature, implement using find_thread_in_random. (for_each_inferior, for_each_inferior_with_data): Change signature, implement using for_each_thread. (add_inferior_to_list, remove_inferior): Remove. (add_thread, get_first_thread, thread_of_pid, find_any_thread_of_pid, free_one_thread, remove_thread): Update. (get_first_inferior, one_inferior_p, clear_inferior_list): Remove. (clear_inferiors, get_thread_process): Update. * gdbthread.h: Include <list>. (struct thread_info) <entry>: Remove field. <id>: New field. (all_threads): Change type to std::list<thread_info *>. (get_first_inferior): Add doc. (find_thread, for_each_thread, find_thread_in_random): New functions. (current_ptid, pid_of, ptid_of, lwpid_of): Update. * linux-arm-low.c (update_registers_callback): Update. * linux-low.c (second_thread_of_pid_p): Update. (kill_one_lwp_callback, linux_detach_lwp_callback, delete_lwp_callback, status_pending_p_callback, same_lwp, find_lwp_pid, num_lwps, iterate_over_lwps_filter, iterate_over_lwps, not_stopped_callback, resume_stopped_resumed_lwps, count_events_callback, select_singlestep_lwp_callback, select_event_lwp_callback, unsuspend_one_lwp, linux_wait_1, send_sigstop_callback, suspend_and_send_sigstop_callback, wait_for_sigstop, stuck_in_jump_pad_callback, move_out_of_jump_pad_callback, lwp_running, linux_set_resume_request, resume_status_pending_p, need_step_over_p, start_step_over, linux_resume_one_thread, proceed_one_lwp, unsuspend_and_proceed_one_lwp, reset_lwp_ptrace_options_callback): Update. * linux-mips-low.c (update_watch_registers_callback): Update. * regcache.c (regcache_invalidate_one, regcache_invalidate): Update. (free_register_cache_thread_one): Remove. (regcache_release): Update. * server.c (handle_btrace_enable_bts, handle_btrace_enable_pt, handle_qxfer_threads_worker): Update. (handle_query): Update, use list iterator. (visit_actioned_threads, handle_pending_status, queue_stop_reply_callback, gdb_wants_all_threads_stopped, clear_pending_status_callback, set_pending_status_callback, find_status_pending_thread_callback, handle_status, process_serial_event): Update. * target.c (thread_search_callback): Update. * thread-db.c (thread_db_get_tls_address): Update. * tracepoint.c (tracepoint_finished_step, tracepoint_was_hit): Update. * win32-i386-low.c (update_debug_registers_callback): Update. * win32-low.c (delete_thread_info, child_delete_thread, continue_one_thread, suspend_one_thread, get_child_debug_event): Adjust.
2017-10-14 15:11:12 +02:00
return false;
});
}
if (remove_single_step_breakpoints_p)
{
/* If we remove single-step breakpoints from memory, stop all lwps,
so that other threads won't hit the breakpoint in the staled
memory. */
stop_all_lwps (0, event_child);
if (non_stop)
{
gdb_assert (has_single_step_breakpoints (current_thread));
delete_single_step_breakpoints (current_thread);
}
else
{
gdbserver: use std::list for all_threads Remove the usage of inferior_list for the all_threads list in gdbserver. The entry field in thread_info is removed, and replaced by a simple ptid field. I added some functions to iterate (for_each_thread) and find threads (find_thread). However, changing all the users of find_inferior & co to use these new functions would have made the patch way too big. So I opted instead to make find_inferior & co some shims, so that the existing code only needs to be updated minimally. We can then update the existing code to use the new functions incrementally (I've started to do the work, but I'll post it afterwards, see [1] if you want a peek). This patch has been built-tested on all relevant platforms, except lynx. I also regtested using the native-gdbserver and native-extended-gdbserver boards on x86. [1] https://github.com/simark/binutils-gdb/commits/kill-inferior-list-entry gdb/gdbserver/ChangeLog: * inferiors.h: (struct inferior_list): Remove. (struct inferior_list_entry); Remove. (add_inferior_to_list, clear_inferior_list, one_inferior_p, A_I_NEXT, ALL_INFERIORS_TYPE, ALL_INFERIORS, remove_inferior, get_first_inferior): Remove. (for_each_inferior, for_each_inferior_with_data, find_inferior, find_inferior_id, find_inferior_in_random): Change signature. * inferiors.c (all_threads): Change type to std::list<thread_info *>. (get_thread): Remove macro. (find_inferior, find_inferior_id): Change signature, implement using find_thread. (find_inferior_in_random): Change signature, implement using find_thread_in_random. (for_each_inferior, for_each_inferior_with_data): Change signature, implement using for_each_thread. (add_inferior_to_list, remove_inferior): Remove. (add_thread, get_first_thread, thread_of_pid, find_any_thread_of_pid, free_one_thread, remove_thread): Update. (get_first_inferior, one_inferior_p, clear_inferior_list): Remove. (clear_inferiors, get_thread_process): Update. * gdbthread.h: Include <list>. (struct thread_info) <entry>: Remove field. <id>: New field. (all_threads): Change type to std::list<thread_info *>. (get_first_inferior): Add doc. (find_thread, for_each_thread, find_thread_in_random): New functions. (current_ptid, pid_of, ptid_of, lwpid_of): Update. * linux-arm-low.c (update_registers_callback): Update. * linux-low.c (second_thread_of_pid_p): Update. (kill_one_lwp_callback, linux_detach_lwp_callback, delete_lwp_callback, status_pending_p_callback, same_lwp, find_lwp_pid, num_lwps, iterate_over_lwps_filter, iterate_over_lwps, not_stopped_callback, resume_stopped_resumed_lwps, count_events_callback, select_singlestep_lwp_callback, select_event_lwp_callback, unsuspend_one_lwp, linux_wait_1, send_sigstop_callback, suspend_and_send_sigstop_callback, wait_for_sigstop, stuck_in_jump_pad_callback, move_out_of_jump_pad_callback, lwp_running, linux_set_resume_request, resume_status_pending_p, need_step_over_p, start_step_over, linux_resume_one_thread, proceed_one_lwp, unsuspend_and_proceed_one_lwp, reset_lwp_ptrace_options_callback): Update. * linux-mips-low.c (update_watch_registers_callback): Update. * regcache.c (regcache_invalidate_one, regcache_invalidate): Update. (free_register_cache_thread_one): Remove. (regcache_release): Update. * server.c (handle_btrace_enable_bts, handle_btrace_enable_pt, handle_qxfer_threads_worker): Update. (handle_query): Update, use list iterator. (visit_actioned_threads, handle_pending_status, queue_stop_reply_callback, gdb_wants_all_threads_stopped, clear_pending_status_callback, set_pending_status_callback, find_status_pending_thread_callback, handle_status, process_serial_event): Update. * target.c (thread_search_callback): Update. * thread-db.c (thread_db_get_tls_address): Update. * tracepoint.c (tracepoint_finished_step, tracepoint_was_hit): Update. * win32-i386-low.c (update_debug_registers_callback): Update. * win32-low.c (delete_thread_info, child_delete_thread, continue_one_thread, suspend_one_thread, get_child_debug_event): Adjust.
2017-10-14 15:11:12 +02:00
for_each_thread ([] (thread_info *thread){
if (has_single_step_breakpoints (thread))
delete_single_step_breakpoints (thread);
});
}
unstop_all_lwps (0, event_child);
}
}
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
if (!stabilizing_threads)
{
/* In all-stop, stop all threads. */
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
if (!non_stop)
stop_all_lwps (0, NULL);
if (step_over_finished)
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
{
if (!non_stop)
{
/* If we were doing a step-over, all other threads but
the stepping one had been paused in start_step_over,
with their suspend counts incremented. We don't want
to do a full unstop/unpause, because we're in
all-stop mode (so we want threads stopped), but we
still need to unsuspend the other threads, to
decrement their `suspended' count back. */
unsuspend_all_lwps (event_child);
}
else
{
/* If we just finished a step-over, then all threads had
been momentarily paused. In all-stop, that's fine,
we want threads stopped by now anyway. In non-stop,
we need to re-resume threads that GDB wanted to be
running. */
unstop_all_lwps (1, event_child);
}
}
/* If we're not waiting for a specific LWP, choose an event LWP
from among those that have had events. Giving equal priority
to all LWPs that have had events helps prevent
starvation. */
2018-06-11 22:45:22 +02:00
if (ptid == minus_one_ptid)
{
event_child->status_pending_p = 1;
event_child->status_pending = w;
select_event_lwp (&event_child);
/* current_thread and event_child must stay in sync. */
current_thread = get_lwp_thread (event_child);
event_child->status_pending_p = 0;
w = event_child->status_pending;
}
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
/* Stabilize threads (move out of jump pads). */
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
if (!non_stop)
target_stabilize_threads ();
}
else
{
/* If we just finished a step-over, then all threads had been
momentarily paused. In all-stop, that's fine, we want
threads stopped by now anyway. In non-stop, we need to
re-resume threads that GDB wanted to be running. */
if (step_over_finished)
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
unstop_all_lwps (1, event_child);
}
Linux gdbserver confused when event randomization picks process exit event The tail end of linux_wait_1 isn't expecting that the select_event_lwp machinery can pick a whole-process exit event to report to GDB. When that happens, both gdb and gdbserver end up quite confused: ... (gdb) [Thread 24971.24971] #1 stopped. 0x0000003615a011f0 in ?? () c& Continuing. (gdb) [New Thread 24971.24981] [New Thread 24983.24983] [New Thread 24971.24982] [Thread 24983.24983] #3 stopped. 0x0000003615ebc7cc in __libc_fork () at ../nptl/sysdeps/unix/sysv/linux/fork.c:130 130 pid = ARCH_FORK (); [New Thread 24984.24984] Error in re-setting breakpoint -16: PC register is not available Error in re-setting breakpoint -17: PC register is not available Error in re-setting breakpoint -18: PC register is not available Error in re-setting breakpoint -19: PC register is not available Error in re-setting breakpoint -24: PC register is not available Error in re-setting breakpoint -25: PC register is not available Error in re-setting breakpoint -26: PC register is not available Error in re-setting breakpoint -27: PC register is not available Error in re-setting breakpoint -28: PC register is not available Error in re-setting breakpoint -29: PC register is not available Error in re-setting breakpoint -30: PC register is not available PC register is not available (gdb) gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (add_lwp): Set waitstatus to TARGET_WAITKIND_IGNORE. (linux_thread_alive): Use lwp_is_marked_dead. (extended_event_reported): Delete. (linux_wait_1): Check if waitstatus is TARGET_WAITKIND_IGNORE instead of extended_event_reported. (mark_lwp_dead): Don't set the 'dead' flag. Store the waitstatus as well. (lwp_is_marked_dead): New function. (lwp_running): Use lwp_is_marked_dead. * linux-low.h: Delete 'dead' field, and update 'waitstatus's comment.
2015-08-06 11:30:17 +02:00
if (event_child->waitstatus.kind != TARGET_WAITKIND_IGNORE)
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
{
Linux gdbserver confused when event randomization picks process exit event The tail end of linux_wait_1 isn't expecting that the select_event_lwp machinery can pick a whole-process exit event to report to GDB. When that happens, both gdb and gdbserver end up quite confused: ... (gdb) [Thread 24971.24971] #1 stopped. 0x0000003615a011f0 in ?? () c& Continuing. (gdb) [New Thread 24971.24981] [New Thread 24983.24983] [New Thread 24971.24982] [Thread 24983.24983] #3 stopped. 0x0000003615ebc7cc in __libc_fork () at ../nptl/sysdeps/unix/sysv/linux/fork.c:130 130 pid = ARCH_FORK (); [New Thread 24984.24984] Error in re-setting breakpoint -16: PC register is not available Error in re-setting breakpoint -17: PC register is not available Error in re-setting breakpoint -18: PC register is not available Error in re-setting breakpoint -19: PC register is not available Error in re-setting breakpoint -24: PC register is not available Error in re-setting breakpoint -25: PC register is not available Error in re-setting breakpoint -26: PC register is not available Error in re-setting breakpoint -27: PC register is not available Error in re-setting breakpoint -28: PC register is not available Error in re-setting breakpoint -29: PC register is not available Error in re-setting breakpoint -30: PC register is not available PC register is not available (gdb) gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (add_lwp): Set waitstatus to TARGET_WAITKIND_IGNORE. (linux_thread_alive): Use lwp_is_marked_dead. (extended_event_reported): Delete. (linux_wait_1): Check if waitstatus is TARGET_WAITKIND_IGNORE instead of extended_event_reported. (mark_lwp_dead): Don't set the 'dead' flag. Store the waitstatus as well. (lwp_is_marked_dead): New function. (lwp_running): Use lwp_is_marked_dead. * linux-low.h: Delete 'dead' field, and update 'waitstatus's comment.
2015-08-06 11:30:17 +02:00
/* If the reported event is an exit, fork, vfork or exec, let
GDB know. */
gdbserver: Leave already-vCont-resumed threads as they were Currently GDB never sends more than one action per vCont packet, when connected in non-stop mode. A follow up patch will change that, and it exposed a gdbserver problem with the vCont handling. For example, this in non-stop mode: => vCont;s:p1.1;c <= OK Should be equivalent to: => vCont;s:p1.1 <= OK => vCont;c <= OK But gdbserver currently doesn't handle this. In the latter case, "vCont;c" makes gdbserver clobber the previous step request. This patch fixes that. Note the server side must ignore resume actions for the thread that has a pending %Stopped notification (and any other threads with events pending), until GDB acks the notification with vStopped. Otherwise, e.g., the following case is mishandled: #1 => g (or any other packet) #2 <= [registers] #3 <= %Stopped T05 thread:p1.2 #4 => vCont s:p1.1;c #5 <= OK Above, the server must not resume thread p1.2 when it processes the vCont. GDB can't know that p1.2 stopped until it acks the %Stopped notification. (Otherwise it wouldn't send a default "c" action.) (The vCont documentation already specifies this.) Finally, special care must also be given to handling fork/vfork events. A (v)fork event actually tells us that two processes stopped -- the parent and the child. Until we follow the fork, we must not resume the child. Therefore, if we have a pending fork follow, we must not send a global wildcard resume action (vCont;c). We can still send process-wide wildcards though. (The comments above will be added as code comments to gdb in a follow up patch.) gdb/gdbserver/ChangeLog: 2016-10-26 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Link parent/child fork threads. (linux_wait_1): Unlink them. (linux_set_resume_request): Ignore resume requests for already-resumed and unhandled fork child threads. * linux-low.h (struct lwp_info) <fork_relative>: New field. * server.c (in_queued_stop_replies_ptid, in_queued_stop_replies): New functions. (handle_v_requests) <vCont>: Don't call require_running. * server.h (in_queued_stop_replies): New declaration.
2016-10-26 17:17:25 +02:00
/* Break the unreported fork relationship chain. */
if (event_child->waitstatus.kind == TARGET_WAITKIND_FORKED
|| event_child->waitstatus.kind == TARGET_WAITKIND_VFORKED)
{
event_child->fork_relative->fork_relative = NULL;
event_child->fork_relative = NULL;
}
Linux gdbserver confused when event randomization picks process exit event The tail end of linux_wait_1 isn't expecting that the select_event_lwp machinery can pick a whole-process exit event to report to GDB. When that happens, both gdb and gdbserver end up quite confused: ... (gdb) [Thread 24971.24971] #1 stopped. 0x0000003615a011f0 in ?? () c& Continuing. (gdb) [New Thread 24971.24981] [New Thread 24983.24983] [New Thread 24971.24982] [Thread 24983.24983] #3 stopped. 0x0000003615ebc7cc in __libc_fork () at ../nptl/sysdeps/unix/sysv/linux/fork.c:130 130 pid = ARCH_FORK (); [New Thread 24984.24984] Error in re-setting breakpoint -16: PC register is not available Error in re-setting breakpoint -17: PC register is not available Error in re-setting breakpoint -18: PC register is not available Error in re-setting breakpoint -19: PC register is not available Error in re-setting breakpoint -24: PC register is not available Error in re-setting breakpoint -25: PC register is not available Error in re-setting breakpoint -26: PC register is not available Error in re-setting breakpoint -27: PC register is not available Error in re-setting breakpoint -28: PC register is not available Error in re-setting breakpoint -29: PC register is not available Error in re-setting breakpoint -30: PC register is not available PC register is not available (gdb) gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (add_lwp): Set waitstatus to TARGET_WAITKIND_IGNORE. (linux_thread_alive): Use lwp_is_marked_dead. (extended_event_reported): Delete. (linux_wait_1): Check if waitstatus is TARGET_WAITKIND_IGNORE instead of extended_event_reported. (mark_lwp_dead): Don't set the 'dead' flag. Store the waitstatus as well. (lwp_is_marked_dead): New function. (lwp_running): Use lwp_is_marked_dead. * linux-low.h: Delete 'dead' field, and update 'waitstatus's comment.
2015-08-06 11:30:17 +02:00
*ourstatus = event_child->waitstatus;
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
/* Clear the event lwp's waitstatus since we handled it already. */
event_child->waitstatus.kind = TARGET_WAITKIND_IGNORE;
}
else
ourstatus->kind = TARGET_WAITKIND_STOPPED;
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
/* Now that we've selected our final event LWP, un-adjust its PC if
it was a software breakpoint, and the client doesn't know we can
adjust the breakpoint ourselves. */
if (event_child->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT
&& !cs.swbreak_feature)
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
{
gdbserver/linux-low: turn the 'decr_pc_after_break' field into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'decr_pc_after_break' linux_target_ops field into a method of linux_process_target. * linux-low.h (struct linux_target_ops) <decr_pc_after_break>: Remove. (class linux_process_target) <low_decr_pc_after_break>: New method declaration. * linux-low.cc (linux_process_target::low_decr_pc_after_break): New method implementation. Update the users below. (linux_process_target::save_stop_reason) (linux_process_target::wait_1) * linux-x86-low.cc (class x86_target) <low_decr_pc_after_break>: New declaration. (x86_target::low_decr_pc_after_break): New method implementation. (the_low_target): Remove the field. * linux-bfin-low.cc (class bfin_target) <low_decr_pc_after_break>: New declaration. (bfin_target::low_decr_pc_after_break): New method implementation. (the_low_target): Remove the field. * linux-m68k-low.cc (class m68k_target) <low_decr_pc_after_break>: New declaration. (m68k_target::low_decr_pc_after_break): New method implementation. (the_low_target): Remove the field. * linux-s390-low.cc (class s390_target) <low_decr_pc_after_break>: New declaration. (s390_target::low_decr_pc_after_break): New method implementation. (the_low_target): Remove the field. * linux-aarch64-low.cc (the_low_target): Remove the field. * linux-arm-low.cc (the_low_target): Remove the field. * linux-cris-low.cc (the_low_target): Remove the field. * linux-crisv32-low.cc (the_low_target): Remove the field. * linux-m32r-low.cc (the_low_target): Remove the field. * linux-mips-low.cc (the_low_target): Remove the field. * linux-nios2-low.cc (the_low_target): Remove the field. * linux-ppc-low.cc (the_low_target): Remove the field. * linux-riscv-low.cc (the_low_target): Remove the field. * linux-sh-low.cc (the_low_target): Remove the field. * linux-sparc-low.cc (the_low_target): Remove the field. * linux-tic6x-low.cc (the_low_target): Remove the field. * linux-tile-low.cc (the_low_target): Remove the field. * linux-xtensa-low.cc (the_low_target): Remove the field.
2020-04-02 15:11:26 +02:00
int decr_pc = low_decr_pc_after_break ();
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
if (decr_pc != 0)
{
struct regcache *regcache
= get_thread_regcache (current_thread, 1);
gdbserver/linux-low: turn 'get_pc' and 'set_pc' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_pc' and 'set_pc' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. * linux-low.cc (supports_breakpoints): Turn into... (linux_process_target::low_supports_breakpoints): ...this. (linux_process_target::low_get_pc): Define. (linux_process_target::low_set_pc): Define. Update the callers below. (linux_process_target::get_pc) (linux_process_target::save_stop_reason) (linux_process_target::maybe_move_out_of_jump_pad) (linux_process_target::wait_1) (linux_process_target::resume_one_lwp_throw) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (linux_process_target::read_pc) (linux_process_target::write_pc) * linux-x86-low.cc (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (x86_target::low_supports_breakpoints): Define. (x86_get_pc): Turn into... (x86_target::low_get_pc): ...this. (x86_set_pc): Turn into... (x86_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (arm_target::low_supports_breakpoints) (arm_target::low_get_pc) (arm_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (bfin_target::low_supports_breakpoints) (bfin_target::low_get_pc) (bfin_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (cris_target::low_supports_breakpoints) (cris_target::low_get_pc) (cris_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (crisv32_target::low_supports_breakpoints) (crisv32_target::low_get_pc) (crisv32_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m32r_target::low_supports_breakpoints) (m32r_target::low_get_pc) (m32r_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m68k_target::low_supports_breakpoints) (m68k_target::low_get_pc) (m68k_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (nios2_target::low_supports_breakpoints) (nios2_target::low_get_pc) (nios2_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (sh_target::low_supports_breakpoints) (sh_target::low_get_pc) (sh_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (xtensa_target::low_supports_breakpoints) (xtensa_target::low_get_pc) (xtensa_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_supports_breakpoints> <low_get_pc>: Declare. (sparc_target::low_supports_breakpoints) (sparc_target::low_get_pc): Define. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tile_target::low_supports_breakpoints) (tile_target::low_get_pc) (tile_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (aarch64_target::low_supports_breakpoints): Define. (aarch64_get_pc): Turn into... (aarch64_target::low_get_pc): ...this. (aarch64_set_pc): Turn into... (aarch64_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (mips_target::low_supports_breakpoints): Define. (mips_get_pc): Turn into... (mips_target::low_get_pc): ...this. (mips_set_pc): Turn into... (mips_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (ppc_target::low_supports_breakpoints): Define. (ppc_get_pc): Turn into... (ppc_target::low_get_pc): ...this. (ppc_set_pc): Turn into... (ppc_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (riscv_target::low_supports_breakpoints): Define. (riscv_get_pc): Turn into... (riscv_target::low_get_pc): ...this. (riscv_set_pc): Turn into... (riscv_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (s390_target::low_supports_breakpoints): Define. (s390_get_pc): Turn into... (s390_target::low_get_pc): ...this. (s390_set_pc): Turn into... (s390_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tic6x_target::low_supports_breakpoints): Define. (tic6x_get_pc): Turn into... (tic6x_target::low_get_pc): ...this. (tic6x_set_pc): Turn into... (tic6x_target::low_set_pc): ...this. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
low_set_pc (regcache, event_child->stop_pc + decr_pc);
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
}
}
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
if (WSTOPSIG (w) == SYSCALL_SIGTRAP)
{
get_syscall_trapinfo (event_child,
&ourstatus->value.syscall_number);
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
ourstatus->kind = event_child->syscall_state;
}
else if (current_thread->last_resume_kind == resume_stop
&& WSTOPSIG (w) == SIGSTOP)
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
{
/* A thread that has been requested to stop by GDB with vCont;t,
and it stopped cleanly, so report as SIG0. The use of
SIGSTOP is an implementation detail. */
gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. gdb/gdbserver/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. include/gdb/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 * gdb/signals.def: Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/arm/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/avr/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/common/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/cr16/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/d10v/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/erc32/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/m32c/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/ppc/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rl78/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout. sim/rx/ 2012-05-24 Pedro Alves <palves@redhat.com> PR gdb/7205 Replace TARGET_SIGNAL_ with GDB_SIGNAL_ throughout.
2012-05-24 18:51:47 +02:00
ourstatus->value.sig = GDB_SIGNAL_0;
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
}
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
else if (current_thread->last_resume_kind == resume_stop
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
&& WSTOPSIG (w) != SIGSTOP)
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
{
/* A thread that has been requested to stop by GDB with vCont;t,
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
but, it stopped for other reasons. */
ourstatus->value.sig = gdb_signal_from_host (WSTOPSIG (w));
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
}
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
else if (ourstatus->kind == TARGET_WAITKIND_STOPPED)
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
{
ourstatus->value.sig = gdb_signal_from_host (WSTOPSIG (w));
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
}
2018-06-11 22:45:22 +02:00
gdb_assert (step_over_bkpt == null_ptid);
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
{
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
debug_printf ("wait_1 ret = %s, %d, %d\n",
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
target_pid_to_str (ptid_of (current_thread)),
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
ourstatus->kind, ourstatus->value.sig);
debug_exit ();
}
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
Remote thread create/exit events When testing with "maint set target-non-stop on", a few threading-related tests expose an issue that requires new RSP packets. Say there are 3 threads running, 1-3. If GDB tries to stop thread 1, 2 and 3, and then waits for their stops, but meanwhile say, thread 2 exits, GDB hangs forever waiting for a stop for thread 2 that won't ever happen. This patch fixes the issue by adding support for thread exit events to the protocol. However, we don't want these always enabled, as they're useless most of the time, and would slow down remote debugging. So I made it so that GDB can enable/disable them, and then made gdb do that around the cases that need it, which currently is only infrun.c:stop_all_threads. In turn, if we have thread exit events, then the extra "thread x exited" traffic slows down attach-many-short-lived-threads.exp enough that gdb has trouble keeping up with new threads that are spawned while gdb tries to stop existing ones. To fix that I added support for the counterpart thread created events too. Enabling those when we try to stop threads ensures that new threads never get a chance to themselves start new threads, killing the race. gdb/doc/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): List "set/show remote thread-events" command in configuration table. (Stop Reply Packets): Document "T05 create" stop reason and 'w' stop reply. (General Query Packets): Document QThreadEvents packet. Document QThreadEvents qSupported feature. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. If GDB wants to hear about thread create events, leave the new child's status pending. (linux_low_filter_event): If GDB wants to hear about thread exit events, leave the LWP marked dead and don't delete it. (linux_wait_for_event_filtered): Don't check for thread exit. (filter_exit_event): New function. (linux_wait_1): Use it, when returning an exit event. (linux_resume_one_lwp_throw): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. * remote-utils.c (prepare_resume_reply): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.c (report_thread_events): New global. (handle_general_set): Handle QThreadEvents. (handle_query) <qSupported>: Handle and report QThreadEvents+; (handle_target_event): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.h (report_thread_events): Declare. gdb/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * NEWS (New commands): Mention "set/show remote thread-events" commands. (New remote packets): Mention thread created/exited stop reasons and QThreadEvents packet. * infrun.c (disable_thread_events): New function. (stop_all_threads): Disable/enable thread create/exit events. Handle TARGET_WAITKIND_THREAD_EXITED. (handle_inferior_event_1): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * remote.c (remove_child_of_pending_fork): Also remove threads of threads that have TARGET_WAITKIND_THREAD_EXITED events. (remote_parse_stop_reply): Handle "create" magic register. Handle 'w' stop reply. (initialize_remote): Install remote_thread_events as to_thread_events target hook. (remote_thread_events): New function. * target-delegates.c: Regenerate. * target.c (target_thread_events): New function. * target.h (struct target_ops) <to_thread_events>: New field. (target_thread_events): Declare. * target/waitstatus.c (target_waitstatus_to_string): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * target/waitstatus.h (enum target_waitkind) <TARGET_WAITKIND_THREAD_CREATED, TARGET_WAITKIND_THREAD_EXITED): New values.
2015-11-30 17:05:21 +01:00
if (ourstatus->kind == TARGET_WAITKIND_EXITED)
return filter_exit_event (event_child, ourstatus);
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
return ptid_of (current_thread);
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
}
/* Get rid of any pending event in the pipe. */
static void
async_file_flush (void)
{
int ret;
char buf;
do
ret = read (linux_event_pipe[0], &buf, 1);
while (ret >= 0 || (ret == -1 && errno == EINTR));
}
/* Put something in the pipe, so the event loop wakes up. */
static void
async_file_mark (void)
{
int ret;
async_file_flush ();
do
ret = write (linux_event_pipe[1], "+", 1);
while (ret == 0 || (ret == -1 && errno == EINTR));
/* Ignore EAGAIN. If the pipe is full, the event loop will already
be awakened anyway. */
}
ptid_t
linux_process_target::wait (ptid_t ptid,
target_waitstatus *ourstatus,
int target_options)
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
{
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
ptid_t event_ptid;
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
/* Flush the async file first. */
if (target_is_async_p ())
async_file_flush ();
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
do
{
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
event_ptid = wait_1 (ptid, ourstatus, target_options);
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
}
while ((target_options & TARGET_WNOHANG) == 0
2018-06-11 22:45:22 +02:00
&& event_ptid == null_ptid
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
&& ourstatus->kind == TARGET_WAITKIND_IGNORE);
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
/* If at least one stop was reported, there may be more. A single
SIGCHLD can signal more than one child stop. */
if (target_is_async_p ()
&& (target_options & TARGET_WNOHANG) != 0
2018-06-11 22:45:22 +02:00
&& event_ptid != null_ptid)
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
async_file_mark ();
return event_ptid;
}
/* Send a signal to an LWP. */
static int
kill_lwp (unsigned long lwpid, int signo)
{
Remove support for LinuxThreads and vendor 2.4 kernels w/ backported NPTL Since we now rely on PTRACE_EVENT_CLONE being available (added in Linux 2.5.46), we're relying on NPTL. This commit removes the support for older LinuxThreads, as well as the workarounds for vendor 2.4 kernels with NPTL backported. - Rely on tkill being available. - Assume gdb doesn't get cancel signals. - Remove code that checks the LinuxThreads restart and cancel signals in the inferior. - Assume that __WALL is available. - Assume that non-leader threads report WIFEXITED. - Thus, no longer need to send signal 0 to check whether threads are still alive. - Update comments throughout. Tested on x86_64 Fedora 20, native and gdbserver. gdb/ChangeLog: * configure.ac: Remove tkill checks. * configure, config.in: Regenerate. * linux-nat.c: Remove HAVE_TKILL_SYSCALL check. Update top level comments. (linux_nat_post_attach_wait): Remove 'cloned' parameter. Use __WALL. (attach_proc_task_lwp_callback): Don't set the cloned flag. (linux_nat_attach): Adjust. (kill_lwp): Remove HAVE_TKILL_SYSCALL check. No longer fall back to 'kill'. (linux_handle_extended_wait): Use __WALL. Don't set the cloned flag. (wait_lwp): Use __WALL. Update comments. (running_callback, stop_and_resume_callback): Delete. (linux_nat_filter_event): Don't stop and resume all lwps. Don't check if the event LWP has previously exited. (check_zombie_leaders): Update comments. (linux_nat_wait_1): Use __WALL. (kill_wait_callback): Don't handle clone processes separately. Use __WALL instead. (linux_thread_alive): Delete. (linux_nat_thread_alive): Return true as long as the LWP is in the LWP list. (linux_nat_update_thread_list): Assume the kernel supports PTRACE_EVENT_CLONE. (get_signo): Delete. (lin_thread_get_thread_signals): Remove LinuxThreads references. No longer check __pthread_sig_restart / __pthread_sig_cancel in the inferior. * linux-nat.h (struct lwp_info) <cloned>: Delete field. * linux-thread-db.c: Update comments. (_initialize_thread_db): Remove LinuxThreads references. * nat/linux-waitpid.c (my_waitpid): No longer emulate __WALL. Pass down flags unmodified. * linux-waitpid.h (my_waitpid): Update documentation. gdb/gdbserver/ChangeLog: * linux-low.c (linux_kill_one_lwp): Remove references to LinuxThreads. (kill_lwp): Remove HAVE_TKILL_SYSCALL check. No longer fall back to 'kill'. (linux_init_signals): Delete. (initialize_low): Adjust. * thread-db.c (thread_db_init): Remove LinuxThreads reference.
2015-12-17 15:20:51 +01:00
int ret;
Remove support for LinuxThreads and vendor 2.4 kernels w/ backported NPTL Since we now rely on PTRACE_EVENT_CLONE being available (added in Linux 2.5.46), we're relying on NPTL. This commit removes the support for older LinuxThreads, as well as the workarounds for vendor 2.4 kernels with NPTL backported. - Rely on tkill being available. - Assume gdb doesn't get cancel signals. - Remove code that checks the LinuxThreads restart and cancel signals in the inferior. - Assume that __WALL is available. - Assume that non-leader threads report WIFEXITED. - Thus, no longer need to send signal 0 to check whether threads are still alive. - Update comments throughout. Tested on x86_64 Fedora 20, native and gdbserver. gdb/ChangeLog: * configure.ac: Remove tkill checks. * configure, config.in: Regenerate. * linux-nat.c: Remove HAVE_TKILL_SYSCALL check. Update top level comments. (linux_nat_post_attach_wait): Remove 'cloned' parameter. Use __WALL. (attach_proc_task_lwp_callback): Don't set the cloned flag. (linux_nat_attach): Adjust. (kill_lwp): Remove HAVE_TKILL_SYSCALL check. No longer fall back to 'kill'. (linux_handle_extended_wait): Use __WALL. Don't set the cloned flag. (wait_lwp): Use __WALL. Update comments. (running_callback, stop_and_resume_callback): Delete. (linux_nat_filter_event): Don't stop and resume all lwps. Don't check if the event LWP has previously exited. (check_zombie_leaders): Update comments. (linux_nat_wait_1): Use __WALL. (kill_wait_callback): Don't handle clone processes separately. Use __WALL instead. (linux_thread_alive): Delete. (linux_nat_thread_alive): Return true as long as the LWP is in the LWP list. (linux_nat_update_thread_list): Assume the kernel supports PTRACE_EVENT_CLONE. (get_signo): Delete. (lin_thread_get_thread_signals): Remove LinuxThreads references. No longer check __pthread_sig_restart / __pthread_sig_cancel in the inferior. * linux-nat.h (struct lwp_info) <cloned>: Delete field. * linux-thread-db.c: Update comments. (_initialize_thread_db): Remove LinuxThreads references. * nat/linux-waitpid.c (my_waitpid): No longer emulate __WALL. Pass down flags unmodified. * linux-waitpid.h (my_waitpid): Update documentation. gdb/gdbserver/ChangeLog: * linux-low.c (linux_kill_one_lwp): Remove references to LinuxThreads. (kill_lwp): Remove HAVE_TKILL_SYSCALL check. No longer fall back to 'kill'. (linux_init_signals): Delete. (initialize_low): Adjust. * thread-db.c (thread_db_init): Remove LinuxThreads reference.
2015-12-17 15:20:51 +01:00
errno = 0;
ret = syscall (__NR_tkill, lwpid, signo);
if (errno == ENOSYS)
{
/* If tkill fails, then we are not using nptl threads, a
configuration we no longer support. */
perror_with_name (("tkill"));
}
return ret;
}
void
linux_stop_lwp (struct lwp_info *lwp)
{
send_sigstop (lwp);
}
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
static void
send_sigstop (struct lwp_info *lwp)
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
{
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
int pid;
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
pid = lwpid_of (get_lwp_thread (lwp));
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
/* If we already have a pending stop signal for this process, don't
send another. */
Rename "process" to "lwp" throughout. * linux-low.c (all_processes): Rename to... (all_lwps): ... this. (inferior_pid, handle_extended_wait, get_stop_pc): Adjust. (add_process): Rename to ... (add_lwp): ... this. Adjust. (linux_create_inferior): Adjust. (linux_attach_lwp): Adjust. (linux_attach): Adjust. (linux_kill_one_process): Rename to ... (linux_kill_one_lwp): ... this. Adjust. (linux_kill): Adjust. (linux_detach_one_process): Rename to ... (linux_detach_one_lwp): ... this. Adjust. (linux_detach): Adjust. (check_removed_breakpoint): Adjust. (status_pending_p): Adjust. (linux_wait_for_process): Rename to ... (linux_wait_for_lwp): ... this. Adjust. (linux_wait_for_event): Adjust. (send_sigstop): Adjust. (wait_for_sigstop): Adjust. (stop_all_processes): Rename to ... (stop_all_lwps): ... this. (linux_resume_one_process): Rename to ... (linux_resume_one_lwp): ... this. Adjust. (linux_set_resume_request, linux_continue_one_thread) (linux_queue_one_thread, resume_status_pending_p) (usr_store_inferior_registers, regsets_store_inferior_registers) (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Adjust. * linux-low.h (get_process): Rename to ... (get_lwp): ... this. Adjust. (get_thread_process): Rename to ... (get_thread_lwp): ... this. Adjust. (get_process_thread): Rename to ... (get_lwp_thread): ... this. Adjust. (struct process_info): Rename to ... (struct lwp_info): ... this. (all_processes): Rename to ... (all_lwps): ... this. * proc-service.c (ps_lgetregs): Adjust. * thread-db.c (thread_db_create_event, find_one_thread) (maybe_attach_thread, thread_db_get_tls_address): Adjust.
2009-03-17 21:25:35 +01:00
if (lwp->stop_expected)
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Have pending sigstop for lwp %d\n", pid);
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
return;
}
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Sending sigstop to lwp %d\n", pid);
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
lwp->stop_expected = 1;
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
kill_lwp (pid, SIGSTOP);
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
}
static void
send_sigstop (thread_info *thread, lwp_info *except)
{
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
struct lwp_info *lwp = get_thread_lwp (thread);
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
/* Ignore EXCEPT. */
if (lwp == except)
return;
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
if (lwp->stopped)
return;
send_sigstop (lwp);
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
}
/* Increment the suspend count of an LWP, and stop it, if not stopped
yet. */
static void
suspend_and_send_sigstop (thread_info *thread, lwp_info *except)
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
{
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
struct lwp_info *lwp = get_thread_lwp (thread);
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
/* Ignore EXCEPT. */
if (lwp == except)
return;
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
gdbserver: Fix non-stop / fork / step-over issues Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html This adds a test that has a multithreaded program have several threads continuously fork, while another thread continuously steps over a breakpoint. This exposes several intertwined issues, which this patch addresses: - When we're stopping and suspending threads, some thread may fork, and we missed setting its suspend count to 1, like we do when a new clone/thread is detected. When we next unsuspend threads, the fork child's suspend count goes below 0, which is bogus and fails an assertion. - If a step-over is cancelled because a signal arrives, but then gdb is not interested in the signal, we pass the signal straight back to the inferior. However, we miss that we need to re-increment the suspend counts of all other threads that had been paused for the step-over. As a result, other threads indefinitely end up stuck stopped. - If a detach request comes in just while gdbserver is handling a step-over (in the test at hand, this is GDB detaching the fork child), gdbserver internal errors in stabilize_thread's helpers, which assert that all thread's suspend counts are 0 (otherwise we wouldn't be able to move threads out of the jump pads). The suspend counts aren't 0 while a step-over is in progress, because all threads but the one stepping past the breakpoint must remain paused until the step-over finishes and the breakpoint can be reinserted. - Occasionally, we see "BAD - reinserting but not stepping." being output (from within linux_resume_one_lwp_throw). That was because GDB pokes memory while gdbserver is busy with a step-over, and that suspends threads, and then re-resumes them with proceed_one_lwp, which missed another reason to tell linux_resume_one_lwp that the thread should be set back to stepping. - In a couple places, we were resuming threads that are meant to be suspended. E.g., when a vCont;c/s request for thread B comes in just while gdbserver is stepping thread A past a breakpoint. The resume for thread B must be deferred until the step-over finishes. - The test runs with both "set detach-on-fork" on and off. When off, it exercises the case of GDB detaching the fork child explicitly. When on, it exercises the case of gdb resuming the child explicitly. In the "off" case, gdb seems to exponentially become slower as new inferiors are created. This is _very_ noticeable as with only 100 inferiors gdb is crawling already, which makes the test take quite a bit to run. For that reason, I've disabled the "off" variant for now. gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * target/waitstatus.h (enum target_stop_reason) <TARGET_STOPPED_BY_SINGLE_STEP>: New value. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the fork child's suspend count if stopping and suspending threads. (check_stopped_by_breakpoint): If stopped by trace, set the LWP's stop reason to TARGET_STOPPED_BY_SINGLE_STEP. (linux_detach): Complete an ongoing step-over. (lwp_suspended_inc, lwp_suspended_decr): New functions. Use throughout. (resume_stopped_resumed_lwps): Don't resume a suspended thread. (linux_wait_1): If passing a signal to the inferior after finishing a step-over, unsuspend and re-resume all lwps. If we see a single-step event but the thread should be continuing, don't pass the trap to gdb. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use internal_error instead of gdb_assert. (enqueue_pending_signal): New function. (check_ptrace_stopped_lwp_gone): Add debug output. (start_step_over): Use internal_error instead of gdb_assert. (complete_ongoing_step_over): New function. (linux_resume_one_thread): Don't resume a suspended thread. (proceed_one_lwp): If the LWP is stepping over a breakpoint, reset it stepping. gdb/testsuite/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * gdb.threads/forking-threads-plus-breakpoint.exp: New file. * gdb.threads/forking-threads-plus-breakpoint.c: New file.
2015-08-06 11:30:18 +02:00
lwp_suspended_inc (lwp);
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
send_sigstop (thread, except);
}
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
static void
mark_lwp_dead (struct lwp_info *lwp, int wstat)
{
/* Store the exit status for later. */
lwp->status_pending_p = 1;
lwp->status_pending = wstat;
Linux gdbserver confused when event randomization picks process exit event The tail end of linux_wait_1 isn't expecting that the select_event_lwp machinery can pick a whole-process exit event to report to GDB. When that happens, both gdb and gdbserver end up quite confused: ... (gdb) [Thread 24971.24971] #1 stopped. 0x0000003615a011f0 in ?? () c& Continuing. (gdb) [New Thread 24971.24981] [New Thread 24983.24983] [New Thread 24971.24982] [Thread 24983.24983] #3 stopped. 0x0000003615ebc7cc in __libc_fork () at ../nptl/sysdeps/unix/sysv/linux/fork.c:130 130 pid = ARCH_FORK (); [New Thread 24984.24984] Error in re-setting breakpoint -16: PC register is not available Error in re-setting breakpoint -17: PC register is not available Error in re-setting breakpoint -18: PC register is not available Error in re-setting breakpoint -19: PC register is not available Error in re-setting breakpoint -24: PC register is not available Error in re-setting breakpoint -25: PC register is not available Error in re-setting breakpoint -26: PC register is not available Error in re-setting breakpoint -27: PC register is not available Error in re-setting breakpoint -28: PC register is not available Error in re-setting breakpoint -29: PC register is not available Error in re-setting breakpoint -30: PC register is not available PC register is not available (gdb) gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (add_lwp): Set waitstatus to TARGET_WAITKIND_IGNORE. (linux_thread_alive): Use lwp_is_marked_dead. (extended_event_reported): Delete. (linux_wait_1): Check if waitstatus is TARGET_WAITKIND_IGNORE instead of extended_event_reported. (mark_lwp_dead): Don't set the 'dead' flag. Store the waitstatus as well. (lwp_is_marked_dead): New function. (lwp_running): Use lwp_is_marked_dead. * linux-low.h: Delete 'dead' field, and update 'waitstatus's comment.
2015-08-06 11:30:17 +02:00
/* Store in waitstatus as well, as there's nothing else to process
for this event. */
if (WIFEXITED (wstat))
{
lwp->waitstatus.kind = TARGET_WAITKIND_EXITED;
lwp->waitstatus.value.integer = WEXITSTATUS (wstat);
}
else if (WIFSIGNALED (wstat))
{
lwp->waitstatus.kind = TARGET_WAITKIND_SIGNALLED;
lwp->waitstatus.value.sig = gdb_signal_from_host (WTERMSIG (wstat));
}
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
/* Prevent trying to stop it. */
lwp->stopped = 1;
/* No further stops are expected from a dead lwp. */
lwp->stop_expected = 0;
}
Linux gdbserver confused when event randomization picks process exit event The tail end of linux_wait_1 isn't expecting that the select_event_lwp machinery can pick a whole-process exit event to report to GDB. When that happens, both gdb and gdbserver end up quite confused: ... (gdb) [Thread 24971.24971] #1 stopped. 0x0000003615a011f0 in ?? () c& Continuing. (gdb) [New Thread 24971.24981] [New Thread 24983.24983] [New Thread 24971.24982] [Thread 24983.24983] #3 stopped. 0x0000003615ebc7cc in __libc_fork () at ../nptl/sysdeps/unix/sysv/linux/fork.c:130 130 pid = ARCH_FORK (); [New Thread 24984.24984] Error in re-setting breakpoint -16: PC register is not available Error in re-setting breakpoint -17: PC register is not available Error in re-setting breakpoint -18: PC register is not available Error in re-setting breakpoint -19: PC register is not available Error in re-setting breakpoint -24: PC register is not available Error in re-setting breakpoint -25: PC register is not available Error in re-setting breakpoint -26: PC register is not available Error in re-setting breakpoint -27: PC register is not available Error in re-setting breakpoint -28: PC register is not available Error in re-setting breakpoint -29: PC register is not available Error in re-setting breakpoint -30: PC register is not available PC register is not available (gdb) gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (add_lwp): Set waitstatus to TARGET_WAITKIND_IGNORE. (linux_thread_alive): Use lwp_is_marked_dead. (extended_event_reported): Delete. (linux_wait_1): Check if waitstatus is TARGET_WAITKIND_IGNORE instead of extended_event_reported. (mark_lwp_dead): Don't set the 'dead' flag. Store the waitstatus as well. (lwp_is_marked_dead): New function. (lwp_running): Use lwp_is_marked_dead. * linux-low.h: Delete 'dead' field, and update 'waitstatus's comment.
2015-08-06 11:30:17 +02:00
/* Return true if LWP has exited already, and has a pending exit event
to report to GDB. */
static int
lwp_is_marked_dead (struct lwp_info *lwp)
{
return (lwp->status_pending_p
&& (WIFEXITED (lwp->status_pending)
|| WIFSIGNALED (lwp->status_pending)));
}
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
void
linux_process_target::wait_for_sigstop ()
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
{
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
struct thread_info *saved_thread;
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
ptid_t saved_tid;
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
int wstat;
int ret;
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
saved_thread = current_thread;
if (saved_thread != NULL)
gdbserver: use std::list for all_threads Remove the usage of inferior_list for the all_threads list in gdbserver. The entry field in thread_info is removed, and replaced by a simple ptid field. I added some functions to iterate (for_each_thread) and find threads (find_thread). However, changing all the users of find_inferior & co to use these new functions would have made the patch way too big. So I opted instead to make find_inferior & co some shims, so that the existing code only needs to be updated minimally. We can then update the existing code to use the new functions incrementally (I've started to do the work, but I'll post it afterwards, see [1] if you want a peek). This patch has been built-tested on all relevant platforms, except lynx. I also regtested using the native-gdbserver and native-extended-gdbserver boards on x86. [1] https://github.com/simark/binutils-gdb/commits/kill-inferior-list-entry gdb/gdbserver/ChangeLog: * inferiors.h: (struct inferior_list): Remove. (struct inferior_list_entry); Remove. (add_inferior_to_list, clear_inferior_list, one_inferior_p, A_I_NEXT, ALL_INFERIORS_TYPE, ALL_INFERIORS, remove_inferior, get_first_inferior): Remove. (for_each_inferior, for_each_inferior_with_data, find_inferior, find_inferior_id, find_inferior_in_random): Change signature. * inferiors.c (all_threads): Change type to std::list<thread_info *>. (get_thread): Remove macro. (find_inferior, find_inferior_id): Change signature, implement using find_thread. (find_inferior_in_random): Change signature, implement using find_thread_in_random. (for_each_inferior, for_each_inferior_with_data): Change signature, implement using for_each_thread. (add_inferior_to_list, remove_inferior): Remove. (add_thread, get_first_thread, thread_of_pid, find_any_thread_of_pid, free_one_thread, remove_thread): Update. (get_first_inferior, one_inferior_p, clear_inferior_list): Remove. (clear_inferiors, get_thread_process): Update. * gdbthread.h: Include <list>. (struct thread_info) <entry>: Remove field. <id>: New field. (all_threads): Change type to std::list<thread_info *>. (get_first_inferior): Add doc. (find_thread, for_each_thread, find_thread_in_random): New functions. (current_ptid, pid_of, ptid_of, lwpid_of): Update. * linux-arm-low.c (update_registers_callback): Update. * linux-low.c (second_thread_of_pid_p): Update. (kill_one_lwp_callback, linux_detach_lwp_callback, delete_lwp_callback, status_pending_p_callback, same_lwp, find_lwp_pid, num_lwps, iterate_over_lwps_filter, iterate_over_lwps, not_stopped_callback, resume_stopped_resumed_lwps, count_events_callback, select_singlestep_lwp_callback, select_event_lwp_callback, unsuspend_one_lwp, linux_wait_1, send_sigstop_callback, suspend_and_send_sigstop_callback, wait_for_sigstop, stuck_in_jump_pad_callback, move_out_of_jump_pad_callback, lwp_running, linux_set_resume_request, resume_status_pending_p, need_step_over_p, start_step_over, linux_resume_one_thread, proceed_one_lwp, unsuspend_and_proceed_one_lwp, reset_lwp_ptrace_options_callback): Update. * linux-mips-low.c (update_watch_registers_callback): Update. * regcache.c (regcache_invalidate_one, regcache_invalidate): Update. (free_register_cache_thread_one): Remove. (regcache_release): Update. * server.c (handle_btrace_enable_bts, handle_btrace_enable_pt, handle_qxfer_threads_worker): Update. (handle_query): Update, use list iterator. (visit_actioned_threads, handle_pending_status, queue_stop_reply_callback, gdb_wants_all_threads_stopped, clear_pending_status_callback, set_pending_status_callback, find_status_pending_thread_callback, handle_status, process_serial_event): Update. * target.c (thread_search_callback): Update. * thread-db.c (thread_db_get_tls_address): Update. * tracepoint.c (tracepoint_finished_step, tracepoint_was_hit): Update. * win32-i386-low.c (update_debug_registers_callback): Update. * win32-low.c (delete_thread_info, child_delete_thread, continue_one_thread, suspend_one_thread, get_child_debug_event): Adjust.
2017-10-14 15:11:12 +02:00
saved_tid = saved_thread->id;
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
else
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
saved_tid = null_ptid; /* avoid bogus unused warning */
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
if (debug_threads)
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
debug_printf ("wait_for_sigstop: pulling events\n");
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
/* Passing NULL_PTID as filter indicates we want all events to be
left pending. Eventually this returns when there are no
unwaited-for children left. */
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
ret = wait_for_event_filtered (minus_one_ptid, null_ptid, &wstat, __WALL);
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
gdb_assert (ret == -1);
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
if (saved_thread == NULL || mythread_alive (saved_tid))
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
current_thread = saved_thread;
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
else
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Previously current thread died.\n");
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
gdbserver: don't pick a random thread if the current thread dies In all-stop mode, if the current thread disappears while stopping all threads, gdbserver calls set_desired_thread(0) ['0' means "I want the continue thread"] which just picks the first thread in the list. This looks like a dangerous thing to do. GDBserver continues processing whatever it was doing, but to the wrong thread. If debugging more than one process, we may even pick the wrong process. Instead, GDBserver should detect the situation and bail out of whatever is was doing. The backends used to pay attention to the set 'cont_thread' (the Hc thread, used in the old way to resume threads, before vCont), but all such 'cont_thread' checks have been eliminated meanwhile. The remaining implicit dependencies that I found on there being a selected thread in the backends are in the Ctrl-C handling, which some backends use as thread to send a signal to. Even that seems to me to be better handled by always using the first thread in the list or by using the signal_pid PID. In order to make this a systematic approach, I'm making set_desired_thread never fallback to a random thread, and instead end up with current_thread == NULL, like already done in non-stop mode. Then I updated all callers to handle the situation. I stumbled on this while fixing other bugs exposed by gdb.threads/fork-plus-threads.exp test. The problems I saw were fixed in a different way, but in any case, I think the potential for problems is more or less obvious, and the resulting code looks a bit less magical to me. Tested on x86-64 Fedora 20, w/ native-extended-gdbserver board. gdb/gdbserver/ChangeLog: 2015-08-21 Pedro Alves <palves@redhat.com> * linux-low.c (wait_for_sigstop): Always switch to no thread selected if the previously current thread dies. * lynx-low.c (lynx_request_interrupt): Use the first thread's process instead of the current thread's. * remote-utils.c (input_interrupt): Don't check if there's no current thread. * server.c (gdb_read_memory, gdb_write_memory): If setting the current thread to the general thread fails, error out. (handle_qxfer_auxv, handle_qxfer_libraries) (handle_qxfer_libraries_svr4, handle_qxfer_siginfo) (handle_qxfer_spu, handle_qxfer_statictrace, handle_qxfer_fdpic) (handle_query): Check if there's a thread selected instead of checking whether there's any thread in the thread list. (handle_qxfer_threads, handle_qxfer_btrace) (handle_qxfer_btrace_conf): Don't error out early if there's no thread in the thread list. (handle_v_cont, myresume): Don't set the current thread to the continue thread. (process_serial_event) <Hg handling>: Also set thread_id if the previous general thread is still alive. (process_serial_event) <g/G handling>: If setting the current thread to the general thread fails, error out. * spu-low.c (spu_resume, spu_request_interrupt): Use the first thread's lwp instead of the current thread's. * target.c (set_desired_thread): If the desired thread was not found, leave the current thread pointing to NULL. Return an int (boolean) indicating success. * target.h (set_desired_thread): Change return type to int.
2015-08-21 20:20:31 +02:00
/* We can't change the current inferior behind GDB's back,
otherwise, a subsequent command may apply to the wrong
process. */
current_thread = NULL;
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
}
}
gdbserver/linux-low: turn 'get_thread_area' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_thread_area' linux target op into a method of process_stratum_target. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <stuck_in_jump_pad> <linux_fast_tracepoint_collecting> <low_get_thread_area>: Declare. * linux-low.cc (supports_fast_tracepoints): Remove. (linux_fast_tracepoint_collecting): Turn into... (linux_process_target::linux_fast_tracepoint_collecting): ...this. (linux_process_target::low_get_thread_area): Define. (stuck_in_jump_pad_callback): Turn into... (linux_process_target::stuck_in_jump_pad): ...this. Update the caller below. (linux_process_target::stabilize_threads) * linux-x86-low.cc (class x86_target) <low_get_thread_area>: Declare. (x86_get_thread_area): Turn into... (x86_target::low_get_thread_area): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <low_get_thread_area>: Declare. (aarch64_get_thread_area): Turn into... (aarch64_target::low_get_thread_area): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (class ppc_target) <low_get_thread_area>: Declare. (ppc_get_thread_area): Turn into... (ppc_target::low_get_thread_area): ...this. (the_low_target): Remove the op field. * linux-s390-low.cc (class s390_target) <low_get_thread_area>: Declare. (s390_get_thread_area): Turn into... (s390_target::low_get_thread_area): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (the_low_target): Remove the op field. * linux-bfin-low.cc (the_low_target): Ditto. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:30 +02:00
bool
linux_process_target::stuck_in_jump_pad (thread_info *thread)
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
{
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
struct lwp_info *lwp = get_thread_lwp (thread);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
gdbserver: Fix non-stop / fork / step-over issues Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html This adds a test that has a multithreaded program have several threads continuously fork, while another thread continuously steps over a breakpoint. This exposes several intertwined issues, which this patch addresses: - When we're stopping and suspending threads, some thread may fork, and we missed setting its suspend count to 1, like we do when a new clone/thread is detected. When we next unsuspend threads, the fork child's suspend count goes below 0, which is bogus and fails an assertion. - If a step-over is cancelled because a signal arrives, but then gdb is not interested in the signal, we pass the signal straight back to the inferior. However, we miss that we need to re-increment the suspend counts of all other threads that had been paused for the step-over. As a result, other threads indefinitely end up stuck stopped. - If a detach request comes in just while gdbserver is handling a step-over (in the test at hand, this is GDB detaching the fork child), gdbserver internal errors in stabilize_thread's helpers, which assert that all thread's suspend counts are 0 (otherwise we wouldn't be able to move threads out of the jump pads). The suspend counts aren't 0 while a step-over is in progress, because all threads but the one stepping past the breakpoint must remain paused until the step-over finishes and the breakpoint can be reinserted. - Occasionally, we see "BAD - reinserting but not stepping." being output (from within linux_resume_one_lwp_throw). That was because GDB pokes memory while gdbserver is busy with a step-over, and that suspends threads, and then re-resumes them with proceed_one_lwp, which missed another reason to tell linux_resume_one_lwp that the thread should be set back to stepping. - In a couple places, we were resuming threads that are meant to be suspended. E.g., when a vCont;c/s request for thread B comes in just while gdbserver is stepping thread A past a breakpoint. The resume for thread B must be deferred until the step-over finishes. - The test runs with both "set detach-on-fork" on and off. When off, it exercises the case of GDB detaching the fork child explicitly. When on, it exercises the case of gdb resuming the child explicitly. In the "off" case, gdb seems to exponentially become slower as new inferiors are created. This is _very_ noticeable as with only 100 inferiors gdb is crawling already, which makes the test take quite a bit to run. For that reason, I've disabled the "off" variant for now. gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * target/waitstatus.h (enum target_stop_reason) <TARGET_STOPPED_BY_SINGLE_STEP>: New value. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the fork child's suspend count if stopping and suspending threads. (check_stopped_by_breakpoint): If stopped by trace, set the LWP's stop reason to TARGET_STOPPED_BY_SINGLE_STEP. (linux_detach): Complete an ongoing step-over. (lwp_suspended_inc, lwp_suspended_decr): New functions. Use throughout. (resume_stopped_resumed_lwps): Don't resume a suspended thread. (linux_wait_1): If passing a signal to the inferior after finishing a step-over, unsuspend and re-resume all lwps. If we see a single-step event but the thread should be continuing, don't pass the trap to gdb. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use internal_error instead of gdb_assert. (enqueue_pending_signal): New function. (check_ptrace_stopped_lwp_gone): Add debug output. (start_step_over): Use internal_error instead of gdb_assert. (complete_ongoing_step_over): New function. (linux_resume_one_thread): Don't resume a suspended thread. (proceed_one_lwp): If the LWP is stepping over a breakpoint, reset it stepping. gdb/testsuite/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * gdb.threads/forking-threads-plus-breakpoint.exp: New file. * gdb.threads/forking-threads-plus-breakpoint.c: New file.
2015-08-06 11:30:18 +02:00
if (lwp->suspended != 0)
{
internal_error (__FILE__, __LINE__,
"LWP %ld is suspended, suspended=%d\n",
lwpid_of (thread), lwp->suspended);
}
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
gdb_assert (lwp->stopped);
/* Allow debugging the jump pad, gdb_collect, etc.. */
return (supports_fast_tracepoints ()
&& agent_loaded_p ()
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
&& (gdb_breakpoint_here (lwp->stop_pc)
|| lwp->stop_reason == TARGET_STOPPED_BY_WATCHPOINT
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
|| thread->last_resume_kind == resume_step)
&& (linux_fast_tracepoint_collecting (lwp, NULL)
!= fast_tpoint_collect_result::not_collecting));
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
}
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
void
linux_process_target::move_out_of_jump_pad (thread_info *thread)
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
{
struct thread_info *saved_thread;
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
struct lwp_info *lwp = get_thread_lwp (thread);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
int *wstat;
gdbserver: Fix non-stop / fork / step-over issues Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html This adds a test that has a multithreaded program have several threads continuously fork, while another thread continuously steps over a breakpoint. This exposes several intertwined issues, which this patch addresses: - When we're stopping and suspending threads, some thread may fork, and we missed setting its suspend count to 1, like we do when a new clone/thread is detected. When we next unsuspend threads, the fork child's suspend count goes below 0, which is bogus and fails an assertion. - If a step-over is cancelled because a signal arrives, but then gdb is not interested in the signal, we pass the signal straight back to the inferior. However, we miss that we need to re-increment the suspend counts of all other threads that had been paused for the step-over. As a result, other threads indefinitely end up stuck stopped. - If a detach request comes in just while gdbserver is handling a step-over (in the test at hand, this is GDB detaching the fork child), gdbserver internal errors in stabilize_thread's helpers, which assert that all thread's suspend counts are 0 (otherwise we wouldn't be able to move threads out of the jump pads). The suspend counts aren't 0 while a step-over is in progress, because all threads but the one stepping past the breakpoint must remain paused until the step-over finishes and the breakpoint can be reinserted. - Occasionally, we see "BAD - reinserting but not stepping." being output (from within linux_resume_one_lwp_throw). That was because GDB pokes memory while gdbserver is busy with a step-over, and that suspends threads, and then re-resumes them with proceed_one_lwp, which missed another reason to tell linux_resume_one_lwp that the thread should be set back to stepping. - In a couple places, we were resuming threads that are meant to be suspended. E.g., when a vCont;c/s request for thread B comes in just while gdbserver is stepping thread A past a breakpoint. The resume for thread B must be deferred until the step-over finishes. - The test runs with both "set detach-on-fork" on and off. When off, it exercises the case of GDB detaching the fork child explicitly. When on, it exercises the case of gdb resuming the child explicitly. In the "off" case, gdb seems to exponentially become slower as new inferiors are created. This is _very_ noticeable as with only 100 inferiors gdb is crawling already, which makes the test take quite a bit to run. For that reason, I've disabled the "off" variant for now. gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * target/waitstatus.h (enum target_stop_reason) <TARGET_STOPPED_BY_SINGLE_STEP>: New value. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the fork child's suspend count if stopping and suspending threads. (check_stopped_by_breakpoint): If stopped by trace, set the LWP's stop reason to TARGET_STOPPED_BY_SINGLE_STEP. (linux_detach): Complete an ongoing step-over. (lwp_suspended_inc, lwp_suspended_decr): New functions. Use throughout. (resume_stopped_resumed_lwps): Don't resume a suspended thread. (linux_wait_1): If passing a signal to the inferior after finishing a step-over, unsuspend and re-resume all lwps. If we see a single-step event but the thread should be continuing, don't pass the trap to gdb. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use internal_error instead of gdb_assert. (enqueue_pending_signal): New function. (check_ptrace_stopped_lwp_gone): Add debug output. (start_step_over): Use internal_error instead of gdb_assert. (complete_ongoing_step_over): New function. (linux_resume_one_thread): Don't resume a suspended thread. (proceed_one_lwp): If the LWP is stepping over a breakpoint, reset it stepping. gdb/testsuite/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * gdb.threads/forking-threads-plus-breakpoint.exp: New file. * gdb.threads/forking-threads-plus-breakpoint.c: New file.
2015-08-06 11:30:18 +02:00
if (lwp->suspended != 0)
{
internal_error (__FILE__, __LINE__,
"LWP %ld is suspended, suspended=%d\n",
lwpid_of (thread), lwp->suspended);
}
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
gdb_assert (lwp->stopped);
/* For gdb_breakpoint_here. */
saved_thread = current_thread;
current_thread = thread;
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
wstat = lwp->status_pending_p ? &lwp->status_pending : NULL;
/* Allow debugging the jump pad, gdb_collect, etc. */
if (!gdb_breakpoint_here (lwp->stop_pc)
&& lwp->stop_reason != TARGET_STOPPED_BY_WATCHPOINT
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
&& thread->last_resume_kind != resume_step
&& maybe_move_out_of_jump_pad (lwp, wstat))
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("LWP %ld needs stabilizing (in jump pad)\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
lwpid_of (thread));
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
if (wstat)
{
lwp->status_pending_p = 0;
enqueue_one_deferred_signal (lwp, wstat);
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Signal %d for LWP %ld deferred "
"(in jump pad)\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
WSTOPSIG (*wstat), lwpid_of (thread));
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
}
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
resume_one_lwp (lwp, 0, 0, NULL);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
}
else
gdbserver: Fix non-stop / fork / step-over issues Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html This adds a test that has a multithreaded program have several threads continuously fork, while another thread continuously steps over a breakpoint. This exposes several intertwined issues, which this patch addresses: - When we're stopping and suspending threads, some thread may fork, and we missed setting its suspend count to 1, like we do when a new clone/thread is detected. When we next unsuspend threads, the fork child's suspend count goes below 0, which is bogus and fails an assertion. - If a step-over is cancelled because a signal arrives, but then gdb is not interested in the signal, we pass the signal straight back to the inferior. However, we miss that we need to re-increment the suspend counts of all other threads that had been paused for the step-over. As a result, other threads indefinitely end up stuck stopped. - If a detach request comes in just while gdbserver is handling a step-over (in the test at hand, this is GDB detaching the fork child), gdbserver internal errors in stabilize_thread's helpers, which assert that all thread's suspend counts are 0 (otherwise we wouldn't be able to move threads out of the jump pads). The suspend counts aren't 0 while a step-over is in progress, because all threads but the one stepping past the breakpoint must remain paused until the step-over finishes and the breakpoint can be reinserted. - Occasionally, we see "BAD - reinserting but not stepping." being output (from within linux_resume_one_lwp_throw). That was because GDB pokes memory while gdbserver is busy with a step-over, and that suspends threads, and then re-resumes them with proceed_one_lwp, which missed another reason to tell linux_resume_one_lwp that the thread should be set back to stepping. - In a couple places, we were resuming threads that are meant to be suspended. E.g., when a vCont;c/s request for thread B comes in just while gdbserver is stepping thread A past a breakpoint. The resume for thread B must be deferred until the step-over finishes. - The test runs with both "set detach-on-fork" on and off. When off, it exercises the case of GDB detaching the fork child explicitly. When on, it exercises the case of gdb resuming the child explicitly. In the "off" case, gdb seems to exponentially become slower as new inferiors are created. This is _very_ noticeable as with only 100 inferiors gdb is crawling already, which makes the test take quite a bit to run. For that reason, I've disabled the "off" variant for now. gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * target/waitstatus.h (enum target_stop_reason) <TARGET_STOPPED_BY_SINGLE_STEP>: New value. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the fork child's suspend count if stopping and suspending threads. (check_stopped_by_breakpoint): If stopped by trace, set the LWP's stop reason to TARGET_STOPPED_BY_SINGLE_STEP. (linux_detach): Complete an ongoing step-over. (lwp_suspended_inc, lwp_suspended_decr): New functions. Use throughout. (resume_stopped_resumed_lwps): Don't resume a suspended thread. (linux_wait_1): If passing a signal to the inferior after finishing a step-over, unsuspend and re-resume all lwps. If we see a single-step event but the thread should be continuing, don't pass the trap to gdb. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use internal_error instead of gdb_assert. (enqueue_pending_signal): New function. (check_ptrace_stopped_lwp_gone): Add debug output. (start_step_over): Use internal_error instead of gdb_assert. (complete_ongoing_step_over): New function. (linux_resume_one_thread): Don't resume a suspended thread. (proceed_one_lwp): If the LWP is stepping over a breakpoint, reset it stepping. gdb/testsuite/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * gdb.threads/forking-threads-plus-breakpoint.exp: New file. * gdb.threads/forking-threads-plus-breakpoint.c: New file.
2015-08-06 11:30:18 +02:00
lwp_suspended_inc (lwp);
current_thread = saved_thread;
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
}
static bool
lwp_running (thread_info *thread)
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
{
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
struct lwp_info *lwp = get_thread_lwp (thread);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
Linux gdbserver confused when event randomization picks process exit event The tail end of linux_wait_1 isn't expecting that the select_event_lwp machinery can pick a whole-process exit event to report to GDB. When that happens, both gdb and gdbserver end up quite confused: ... (gdb) [Thread 24971.24971] #1 stopped. 0x0000003615a011f0 in ?? () c& Continuing. (gdb) [New Thread 24971.24981] [New Thread 24983.24983] [New Thread 24971.24982] [Thread 24983.24983] #3 stopped. 0x0000003615ebc7cc in __libc_fork () at ../nptl/sysdeps/unix/sysv/linux/fork.c:130 130 pid = ARCH_FORK (); [New Thread 24984.24984] Error in re-setting breakpoint -16: PC register is not available Error in re-setting breakpoint -17: PC register is not available Error in re-setting breakpoint -18: PC register is not available Error in re-setting breakpoint -19: PC register is not available Error in re-setting breakpoint -24: PC register is not available Error in re-setting breakpoint -25: PC register is not available Error in re-setting breakpoint -26: PC register is not available Error in re-setting breakpoint -27: PC register is not available Error in re-setting breakpoint -28: PC register is not available Error in re-setting breakpoint -29: PC register is not available Error in re-setting breakpoint -30: PC register is not available PC register is not available (gdb) gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (add_lwp): Set waitstatus to TARGET_WAITKIND_IGNORE. (linux_thread_alive): Use lwp_is_marked_dead. (extended_event_reported): Delete. (linux_wait_1): Check if waitstatus is TARGET_WAITKIND_IGNORE instead of extended_event_reported. (mark_lwp_dead): Don't set the 'dead' flag. Store the waitstatus as well. (lwp_is_marked_dead): New function. (lwp_running): Use lwp_is_marked_dead. * linux-low.h: Delete 'dead' field, and update 'waitstatus's comment.
2015-08-06 11:30:17 +02:00
if (lwp_is_marked_dead (lwp))
return false;
return !lwp->stopped;
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
}
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
void
linux_process_target::stop_all_lwps (int suspend, lwp_info *except)
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
{
/* Should not be called recursively. */
gdb_assert (stopping_threads == NOT_STOPPING_THREADS);
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
if (debug_threads)
{
debug_enter ();
debug_printf ("stop_all_lwps (%s, except=%s)\n",
suspend ? "stop-and-suspend" : "stop",
except != NULL
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
? target_pid_to_str (ptid_of (get_lwp_thread (except)))
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
: "none");
}
stopping_threads = (suspend
? STOPPING_AND_SUSPENDING_THREADS
: STOPPING_THREADS);
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
if (suspend)
for_each_thread ([&] (thread_info *thread)
{
suspend_and_send_sigstop (thread, except);
});
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
else
for_each_thread ([&] (thread_info *thread)
{
send_sigstop (thread, except);
});
Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27 15:30:08 +01:00
wait_for_sigstop ();
stopping_threads = NOT_STOPPING_THREADS;
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
if (debug_threads)
{
debug_printf ("stop_all_lwps done, setting stopping_threads "
"back to !stopping\n");
debug_exit ();
}
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
}
gdbserver: Fix non-stop / fork / step-over issues Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html This adds a test that has a multithreaded program have several threads continuously fork, while another thread continuously steps over a breakpoint. This exposes several intertwined issues, which this patch addresses: - When we're stopping and suspending threads, some thread may fork, and we missed setting its suspend count to 1, like we do when a new clone/thread is detected. When we next unsuspend threads, the fork child's suspend count goes below 0, which is bogus and fails an assertion. - If a step-over is cancelled because a signal arrives, but then gdb is not interested in the signal, we pass the signal straight back to the inferior. However, we miss that we need to re-increment the suspend counts of all other threads that had been paused for the step-over. As a result, other threads indefinitely end up stuck stopped. - If a detach request comes in just while gdbserver is handling a step-over (in the test at hand, this is GDB detaching the fork child), gdbserver internal errors in stabilize_thread's helpers, which assert that all thread's suspend counts are 0 (otherwise we wouldn't be able to move threads out of the jump pads). The suspend counts aren't 0 while a step-over is in progress, because all threads but the one stepping past the breakpoint must remain paused until the step-over finishes and the breakpoint can be reinserted. - Occasionally, we see "BAD - reinserting but not stepping." being output (from within linux_resume_one_lwp_throw). That was because GDB pokes memory while gdbserver is busy with a step-over, and that suspends threads, and then re-resumes them with proceed_one_lwp, which missed another reason to tell linux_resume_one_lwp that the thread should be set back to stepping. - In a couple places, we were resuming threads that are meant to be suspended. E.g., when a vCont;c/s request for thread B comes in just while gdbserver is stepping thread A past a breakpoint. The resume for thread B must be deferred until the step-over finishes. - The test runs with both "set detach-on-fork" on and off. When off, it exercises the case of GDB detaching the fork child explicitly. When on, it exercises the case of gdb resuming the child explicitly. In the "off" case, gdb seems to exponentially become slower as new inferiors are created. This is _very_ noticeable as with only 100 inferiors gdb is crawling already, which makes the test take quite a bit to run. For that reason, I've disabled the "off" variant for now. gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * target/waitstatus.h (enum target_stop_reason) <TARGET_STOPPED_BY_SINGLE_STEP>: New value. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the fork child's suspend count if stopping and suspending threads. (check_stopped_by_breakpoint): If stopped by trace, set the LWP's stop reason to TARGET_STOPPED_BY_SINGLE_STEP. (linux_detach): Complete an ongoing step-over. (lwp_suspended_inc, lwp_suspended_decr): New functions. Use throughout. (resume_stopped_resumed_lwps): Don't resume a suspended thread. (linux_wait_1): If passing a signal to the inferior after finishing a step-over, unsuspend and re-resume all lwps. If we see a single-step event but the thread should be continuing, don't pass the trap to gdb. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use internal_error instead of gdb_assert. (enqueue_pending_signal): New function. (check_ptrace_stopped_lwp_gone): Add debug output. (start_step_over): Use internal_error instead of gdb_assert. (complete_ongoing_step_over): New function. (linux_resume_one_thread): Don't resume a suspended thread. (proceed_one_lwp): If the LWP is stepping over a breakpoint, reset it stepping. gdb/testsuite/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * gdb.threads/forking-threads-plus-breakpoint.exp: New file. * gdb.threads/forking-threads-plus-breakpoint.c: New file.
2015-08-06 11:30:18 +02:00
/* Enqueue one signal in the chain of signals which need to be
delivered to this process on next resume. */
static void
enqueue_pending_signal (struct lwp_info *lwp, int signal, siginfo_t *info)
{
gdbserver/linux-low: use std::list to store pending signals Use std::list to store pending signals instead of a manually-managed linked list. This is a refactoring. In the existing code, pending signals are kept in a manually-created linked list with "prev" pointers. A new pending signal is thus inserted to the beginning of the list. When consuming, GDB goes until the end of the list, following the "prev" pointers, and processes the final item. With this patch, a new item is added to the end of the list and the item at the front of the list is consumed. In other words, the list elements used to be stored in reverse order; with this patch, they are stored in their order of arrival. This causes a change in the debug messages that print the pending signals. Otherwise, no behavioral change is expected. gdbserver/ChangeLog: 2020-06-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Use std::list to stop pending signal instead of manually-created linked list. * linux-low.h: Include <list>. (struct pending_signal): Move here from linux-low.cc. (struct lwp_info) <pending_signals> <pending_signals_to_report>: Update the type. * linux-low.cc (struct pending_signals): Remove. (linux_process_target::delete_lwp) (linux_process_target::add_lwp) (enqueue_one_deferred_signal) (dequeue_one_deferred_signal) (enqueue_pending_signal) (linux_process_target::resume_one_lwp_throw) (linux_process_target::thread_needs_step_over) (linux_process_target::resume_one_thread) (linux_process_target::proceed_one_lwp): Update the use of pending signal list.
2020-06-22 14:13:48 +02:00
lwp->pending_signals.emplace_back (signal);
if (info == nullptr)
memset (&lwp->pending_signals.back ().info, 0, sizeof (siginfo_t));
gdbserver: Fix non-stop / fork / step-over issues Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html This adds a test that has a multithreaded program have several threads continuously fork, while another thread continuously steps over a breakpoint. This exposes several intertwined issues, which this patch addresses: - When we're stopping and suspending threads, some thread may fork, and we missed setting its suspend count to 1, like we do when a new clone/thread is detected. When we next unsuspend threads, the fork child's suspend count goes below 0, which is bogus and fails an assertion. - If a step-over is cancelled because a signal arrives, but then gdb is not interested in the signal, we pass the signal straight back to the inferior. However, we miss that we need to re-increment the suspend counts of all other threads that had been paused for the step-over. As a result, other threads indefinitely end up stuck stopped. - If a detach request comes in just while gdbserver is handling a step-over (in the test at hand, this is GDB detaching the fork child), gdbserver internal errors in stabilize_thread's helpers, which assert that all thread's suspend counts are 0 (otherwise we wouldn't be able to move threads out of the jump pads). The suspend counts aren't 0 while a step-over is in progress, because all threads but the one stepping past the breakpoint must remain paused until the step-over finishes and the breakpoint can be reinserted. - Occasionally, we see "BAD - reinserting but not stepping." being output (from within linux_resume_one_lwp_throw). That was because GDB pokes memory while gdbserver is busy with a step-over, and that suspends threads, and then re-resumes them with proceed_one_lwp, which missed another reason to tell linux_resume_one_lwp that the thread should be set back to stepping. - In a couple places, we were resuming threads that are meant to be suspended. E.g., when a vCont;c/s request for thread B comes in just while gdbserver is stepping thread A past a breakpoint. The resume for thread B must be deferred until the step-over finishes. - The test runs with both "set detach-on-fork" on and off. When off, it exercises the case of GDB detaching the fork child explicitly. When on, it exercises the case of gdb resuming the child explicitly. In the "off" case, gdb seems to exponentially become slower as new inferiors are created. This is _very_ noticeable as with only 100 inferiors gdb is crawling already, which makes the test take quite a bit to run. For that reason, I've disabled the "off" variant for now. gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * target/waitstatus.h (enum target_stop_reason) <TARGET_STOPPED_BY_SINGLE_STEP>: New value. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the fork child's suspend count if stopping and suspending threads. (check_stopped_by_breakpoint): If stopped by trace, set the LWP's stop reason to TARGET_STOPPED_BY_SINGLE_STEP. (linux_detach): Complete an ongoing step-over. (lwp_suspended_inc, lwp_suspended_decr): New functions. Use throughout. (resume_stopped_resumed_lwps): Don't resume a suspended thread. (linux_wait_1): If passing a signal to the inferior after finishing a step-over, unsuspend and re-resume all lwps. If we see a single-step event but the thread should be continuing, don't pass the trap to gdb. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use internal_error instead of gdb_assert. (enqueue_pending_signal): New function. (check_ptrace_stopped_lwp_gone): Add debug output. (start_step_over): Use internal_error instead of gdb_assert. (complete_ongoing_step_over): New function. (linux_resume_one_thread): Don't resume a suspended thread. (proceed_one_lwp): If the LWP is stepping over a breakpoint, reset it stepping. gdb/testsuite/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * gdb.threads/forking-threads-plus-breakpoint.exp: New file. * gdb.threads/forking-threads-plus-breakpoint.c: New file.
2015-08-06 11:30:18 +02:00
else
gdbserver/linux-low: use std::list to store pending signals Use std::list to store pending signals instead of a manually-managed linked list. This is a refactoring. In the existing code, pending signals are kept in a manually-created linked list with "prev" pointers. A new pending signal is thus inserted to the beginning of the list. When consuming, GDB goes until the end of the list, following the "prev" pointers, and processes the final item. With this patch, a new item is added to the end of the list and the item at the front of the list is consumed. In other words, the list elements used to be stored in reverse order; with this patch, they are stored in their order of arrival. This causes a change in the debug messages that print the pending signals. Otherwise, no behavioral change is expected. gdbserver/ChangeLog: 2020-06-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Use std::list to stop pending signal instead of manually-created linked list. * linux-low.h: Include <list>. (struct pending_signal): Move here from linux-low.cc. (struct lwp_info) <pending_signals> <pending_signals_to_report>: Update the type. * linux-low.cc (struct pending_signals): Remove. (linux_process_target::delete_lwp) (linux_process_target::add_lwp) (enqueue_one_deferred_signal) (dequeue_one_deferred_signal) (enqueue_pending_signal) (linux_process_target::resume_one_lwp_throw) (linux_process_target::thread_needs_step_over) (linux_process_target::resume_one_thread) (linux_process_target::proceed_one_lwp): Update the use of pending signal list.
2020-06-22 14:13:48 +02:00
lwp->pending_signals.back ().info = *info;
gdbserver: Fix non-stop / fork / step-over issues Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html This adds a test that has a multithreaded program have several threads continuously fork, while another thread continuously steps over a breakpoint. This exposes several intertwined issues, which this patch addresses: - When we're stopping and suspending threads, some thread may fork, and we missed setting its suspend count to 1, like we do when a new clone/thread is detected. When we next unsuspend threads, the fork child's suspend count goes below 0, which is bogus and fails an assertion. - If a step-over is cancelled because a signal arrives, but then gdb is not interested in the signal, we pass the signal straight back to the inferior. However, we miss that we need to re-increment the suspend counts of all other threads that had been paused for the step-over. As a result, other threads indefinitely end up stuck stopped. - If a detach request comes in just while gdbserver is handling a step-over (in the test at hand, this is GDB detaching the fork child), gdbserver internal errors in stabilize_thread's helpers, which assert that all thread's suspend counts are 0 (otherwise we wouldn't be able to move threads out of the jump pads). The suspend counts aren't 0 while a step-over is in progress, because all threads but the one stepping past the breakpoint must remain paused until the step-over finishes and the breakpoint can be reinserted. - Occasionally, we see "BAD - reinserting but not stepping." being output (from within linux_resume_one_lwp_throw). That was because GDB pokes memory while gdbserver is busy with a step-over, and that suspends threads, and then re-resumes them with proceed_one_lwp, which missed another reason to tell linux_resume_one_lwp that the thread should be set back to stepping. - In a couple places, we were resuming threads that are meant to be suspended. E.g., when a vCont;c/s request for thread B comes in just while gdbserver is stepping thread A past a breakpoint. The resume for thread B must be deferred until the step-over finishes. - The test runs with both "set detach-on-fork" on and off. When off, it exercises the case of GDB detaching the fork child explicitly. When on, it exercises the case of gdb resuming the child explicitly. In the "off" case, gdb seems to exponentially become slower as new inferiors are created. This is _very_ noticeable as with only 100 inferiors gdb is crawling already, which makes the test take quite a bit to run. For that reason, I've disabled the "off" variant for now. gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * target/waitstatus.h (enum target_stop_reason) <TARGET_STOPPED_BY_SINGLE_STEP>: New value. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the fork child's suspend count if stopping and suspending threads. (check_stopped_by_breakpoint): If stopped by trace, set the LWP's stop reason to TARGET_STOPPED_BY_SINGLE_STEP. (linux_detach): Complete an ongoing step-over. (lwp_suspended_inc, lwp_suspended_decr): New functions. Use throughout. (resume_stopped_resumed_lwps): Don't resume a suspended thread. (linux_wait_1): If passing a signal to the inferior after finishing a step-over, unsuspend and re-resume all lwps. If we see a single-step event but the thread should be continuing, don't pass the trap to gdb. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use internal_error instead of gdb_assert. (enqueue_pending_signal): New function. (check_ptrace_stopped_lwp_gone): Add debug output. (start_step_over): Use internal_error instead of gdb_assert. (complete_ongoing_step_over): New function. (linux_resume_one_thread): Don't resume a suspended thread. (proceed_one_lwp): If the LWP is stepping over a breakpoint, reset it stepping. gdb/testsuite/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * gdb.threads/forking-threads-plus-breakpoint.exp: New file. * gdb.threads/forking-threads-plus-breakpoint.c: New file.
2015-08-06 11:30:18 +02:00
}
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
void
linux_process_target::install_software_single_step_breakpoints (lwp_info *lwp)
{
struct thread_info *thread = get_lwp_thread (lwp);
struct regcache *regcache = get_thread_regcache (thread, 1);
scoped_restore save_current_thread = make_scoped_restore (&current_thread);
current_thread = thread;
gdbserver/linux-low: turn 'supports_software_single_step' and 'get_next_pcs' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Remove the 'supports_software_single_step' linux target op and let the concrete linux target define it by overriding the op in process_stratum_target. Turn the 'get_next_pcs' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <supports_software_single_step>: Remove. <low_get_next_pcs>: Declare. * linux-low.cc (can_software_single_step): Remove. (linux_process_target::low_get_next_pcs): Define. (linux_process_target::supports_software_single_step): Remove. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::wait_1) (linux_process_target::install_software_single_step_breakpoints) (linux_process_target::single_step) (linux_process_target::thread_needs_step_over) (linux_process_target::proceed_one_lwp) (linux_process_target::supports_range_stepping) * linux-x86-low.cc (the_low_target): Remove the op field. * linux-aarch64-low.cc (the_low_target): Ditto. * linux-bfin-low.cc (the_low_target): Ditto. * linux-cris-low.cc (the_low_target): Ditto. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-mips-low.cc (the_low_target): Ditto. * linux-nios2-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-riscv-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-sparc-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto. * linux-arm-low.cc (class arm_target) <low_get_next_pcs> <supports_software_single_step>: Declare. (arm_target::supports_software_single_step): Define. (arm_gdbserver_get_next_pcs): Turn into... (arm_target::low_get_next_pcs): ...this. (the_low_target): Remove the op field.
2020-04-02 15:11:26 +02:00
std::vector<CORE_ADDR> next_pcs = low_get_next_pcs (regcache);
Change return type of gdbarch_software_single_step to vector<CORE_ADDR> This is a relatively straightforward patch that changes gdbarch_software_single_step so it returns an std::vector<CORE_ADDR> instead of a VEC (CORE_ADDR). gdb/ChangeLog: * gdbarch.sh (software_single_step): Change return type to std::vector<CORE_ADDR>. * gdbarch.c, gdbarch.h: Re-generate. * arch/arm-get-next-pcs.c (thumb_deal_with_atomic_sequence_raw): Adjust. (arm_deal_with_atomic_sequence_raw): Adjust. (thumb_get_next_pcs_raw): Adjust. (arm_get_next_pcs_raw): Adjust. (arm_get_next_pcs): Adjust. * arch/arm-get-next-pcs.h (arm_get_next_pcs): Adjust. * aarch64-tdep.c (aarch64_software_single_step): Adjust. * alpha-tdep.c (alpha_deal_with_atomic_sequence): Adjust. (alpha_software_single_step): Adjust. * alpha-tdep.h (alpha_software_single_step): Adjust. * arm-linux-tdep.c (arm_linux_software_single_step): Adjust. * arm-tdep.c (arm_software_single_step): Adjust. (arm_breakpoint_kind_from_current_state): Adjust. * arm-tdep.h (arm_software_single_step): Adjust. * breakpoint.c (insert_single_step_breakpoint): Adjust. * cris-tdep.c (cris_software_single_step): Adjust. * mips-tdep.c (mips_deal_with_atomic_sequence): Adjust. (micromips_deal_with_atomic_sequence): Adjust. (deal_with_atomic_sequence): Adjust. (mips_software_single_step): Adjust. * mips-tdep.h (mips_software_single_step): Adjust. * moxie-tdep.c (moxie_software_single_step): Adjust. * nios2-tdep.c (nios2_software_single_step): Adjust. * ppc-tdep.h (ppc_deal_with_atomic_sequence): Adjust. * rs6000-aix-tdep.c (rs6000_software_single_step): Adjust. * rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust. * s390-linux-tdep.c (s390_software_single_step): Adjust. * sparc-tdep.c (sparc_software_single_step): Adjust. * spu-tdep.c (spu_software_single_step): Adjust. * tic6x-tdep.c (tic6x_software_single_step): Adjust. gdb/gdbserver/ChangeLog: * linux-arm-low.c (arm_gdbserver_get_next_pcs): Adjust to software_single_step change of return type to std::vector<CORE_ADDR>. * linux-low.c (install_software_single_step_breakpoints): Likewise. * linux-low.h (install_software_single_step_breakpoints): Likewise.
2017-05-02 19:30:07 +02:00
for (CORE_ADDR pc : next_pcs)
set_single_step_breakpoint (pc, current_ptid);
}
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
int
linux_process_target::single_step (lwp_info* lwp)
{
int step = 0;
gdbserver/linux-low: turn 'supports_hardware_single_step' into a method All the linux low targets except arm define the 'supports_hardware_single_step' op to return true. Hence, we override the method to return true in linux_process_target, and remove the definitions in all the linux low targets but arm. gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Remove the 'supports_hardware_single_step' linux target op and override the process_stratum_target's op definition in linux_process_target to return true. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <finish_step_over> <maybe_hw_step>: Declare. * linux-low.cc (can_hardware_single_step): Remove. (maybe_hw_step): Turn into... (linux_process_target::maybe_hw_step): ...this. (finish_step_over): Turn into... (linux_process_target::finish_step_over): ...this. (linux_process_target::supports_hardware_single_step): Update to return true. Update the callers below. (linux_process_target::single_step) (linux_process_target::resume_one_lwp_throw) * linux-arm-low.cc (class arm_target) <supports_hardware_single_step>: Declare. (arm_supports_hardware_single_step): Turn into... (arm_target::supports_hardware_single_step): ...this. (the_low_target): Remove the op field. * linux-x86-low.cc (x86_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-aarch64-low.cc (aarch64_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-bfin-low.cc (bfin_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-crisv32-low.cc (cris_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-m32r-low.cc (m32r_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-m68k-low.cc (m68k_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-ppc-low.cc (ppc_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-s390-low.cc (s390_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-sh-low.cc (sh_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-tic6x-low.cc (tic6x_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-tile-low.cc (tile_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-xtensa-low.cc (xtensa_supports_hardware_single_step): Remove. (the_low_target): Remove the op field.
2020-04-02 15:11:31 +02:00
if (supports_hardware_single_step ())
{
step = 1;
}
gdbserver/linux-low: turn 'supports_software_single_step' and 'get_next_pcs' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Remove the 'supports_software_single_step' linux target op and let the concrete linux target define it by overriding the op in process_stratum_target. Turn the 'get_next_pcs' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <supports_software_single_step>: Remove. <low_get_next_pcs>: Declare. * linux-low.cc (can_software_single_step): Remove. (linux_process_target::low_get_next_pcs): Define. (linux_process_target::supports_software_single_step): Remove. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::wait_1) (linux_process_target::install_software_single_step_breakpoints) (linux_process_target::single_step) (linux_process_target::thread_needs_step_over) (linux_process_target::proceed_one_lwp) (linux_process_target::supports_range_stepping) * linux-x86-low.cc (the_low_target): Remove the op field. * linux-aarch64-low.cc (the_low_target): Ditto. * linux-bfin-low.cc (the_low_target): Ditto. * linux-cris-low.cc (the_low_target): Ditto. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-mips-low.cc (the_low_target): Ditto. * linux-nios2-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-riscv-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-sparc-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto. * linux-arm-low.cc (class arm_target) <low_get_next_pcs> <supports_software_single_step>: Declare. (arm_target::supports_software_single_step): Define. (arm_gdbserver_get_next_pcs): Turn into... (arm_target::low_get_next_pcs): ...this. (the_low_target): Remove the op field.
2020-04-02 15:11:26 +02:00
else if (supports_software_single_step ())
{
install_software_single_step_breakpoints (lwp);
step = 0;
}
else
{
if (debug_threads)
debug_printf ("stepping is not implemented on this target");
}
return step;
}
/* The signal can be delivered to the inferior if we are not trying to
Deliver signal in hardware single step GDBserver doesn't deliver signal when stepping over a breakpoint even hardware single step is used. When GDBserver started to step over (thread creation) breakpoint for mutlit-threaded debugging in 2002 [1], GDBserver behaves this way. This behavior gets trouble on conditional breakpoints on branch to self instruction like this, 0x00000000004005b6 <+29>: jmp 0x4005b6 <main+29> and I set breakpoint $(gdb) break branch-to-self.c:43 if counter > 3 and the variable counter will be set to 5 in SIGALRM signal handler. Since GDBserver keeps stepping over breakpoint, the SIGALRM can never be dequeued and delivered to the inferior, so the program can't stop. The test can be found in gdb.base/branch-to-self.exp. GDBserver didn't deliver signal when stepping over a breakpoint because a tracepoint is collected twice if GDBserver does so in the following scenario, which can be reproduced by gdb.trace/signal.exp. - program stops at tracepoint, and tracepoint is collected, - gdbserver starts a step-over, - a signal arrives, step-over is canceled, and signal should be passed, - gdbserver starts a new step-over again, pass the signal as well, - program stops at the entry of signal handler, step-over finished, - gdbserver proceeds, - program returns from the signal handler, again to the tracepoint, and thus is collected again. The spurious collection isn't that harmful, IMO, so it should be OK to let GDBserver deliver signal when stepping over a breakpoint. gdb/gdbserver: 2016-04-22 Yao Qi <yao.qi@linaro.org> * linux-low.c (lwp_signal_can_be_delivered): Don't deliver signal when stepping over breakpoint with software single step. gdb/testsuite: 2016-04-22 Yao Qi <yao.qi@linaro.org> * gdb.trace/signal.exp: Also pass if $tracepoint_hits($i) > $iterations.
2016-04-22 12:59:18 +02:00
finish a fast tracepoint collect. Since signal can be delivered in
the step-over, the program may go to signal handler and trap again
after return from the signal handler. We can live with the spurious
double traps. */
static int
lwp_signal_can_be_delivered (struct lwp_info *lwp)
{
return (lwp->collecting_fast_tracepoint
== fast_tpoint_collect_result::not_collecting);
}
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
void
linux_process_target::resume_one_lwp_throw (lwp_info *lwp, int step,
int signal, siginfo_t *info)
{
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
struct thread_info *thread = get_lwp_thread (lwp);
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
struct thread_info *saved_thread;
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
int ptrace_request;
Initialise target descrption after skipping extra traps for --wrapper Nowadays, when --wrapper is used, GDBserver skips extra traps/stops in the wrapper program, and stops at the first instruction of the program to be debugged. However, GDBserver created target description in the first stop of inferior, and the executable of the inferior is the wrapper program rather than the program to be debugged. In this way, the target description can be wrong if the architectures of wrapper program and program to be debugged are different. This is shown by some fails in gdb.server/wrapper.exp on buildbot. We are testing i686-linux GDB (Fedora-i686) on an x86_64-linux box (fedora-x86-64-4) in buildbot, such configuration causes fails in gdb.server/wrapper.exp like this: spawn /home/gdb-buildbot-2/fedora-x86-64-4/fedora-i686/build/gdb/testsuite/../../gdb/gdbserver/gdbserver --once --wrapper env TEST=1 -- :2346 /home/gdb-buildbot-2/fedora-x86-64-4/fedora-i686/build/gdb/testsuite/outputs/gdb.server/wrapper/wrapper Process /home/gdb-buildbot-2/fedora-x86-64-4/fedora-i686/build/gdb/testsuite/outputs/gdb.server/wrapper/wrapper created; pid = 8795 Can't debug 64-bit process with 32-bit GDBserver Exiting target remote localhost:2346 localhost:2346: Connection timed out. (gdb) FAIL: gdb.server/wrapper.exp: setting breakpoint at marker See https://sourceware.org/ml/gdb-testers/2015-q3/msg01541.html In this case, program to be debugged ("wrapper") is 32-bit but wrapper program ("/usr/bin/env") is 64-bit, so GDBserver gets the 64-bit target description instead of 32-bit. The root cause of this problem is that GDBserver creates target description too early, and the rationale of fix could be creating target description once the GDBserver skips extra traps and inferior stops at the first instruction of the program we want to debug. IOW, when GDBserver skips extra traps, the inferior's tdesc is NULL, and mywait and its callees shouldn't use inferior's tdesc, so in this patch, we skip code that requires register access, see changes in linux_resume_one_lwp_throw and need_step_over_p. In linux_low_filter_event, if target description isn't initialised and GDBserver attached the process, we create target description immediately, because GDBserver don't have to skip extra traps for attach, IOW, it makes no sense to use --attach and --wrapper together. Otherwise, the process is launched by GDBserver, we keep the status pending, and return. After GDBserver skipped extra traps in start_inferior, we call a target_ops hook arch_setup to initialise target description there. gdb/gdbserver: 2015-07-24 Yao Qi <yao.qi@linaro.org> * linux-low.c (linux_arch_setup): New function. (linux_low_filter_event): If proc->tdesc is NULL and proc->attached is true, call the_low_target.arch_setup. Otherwise, keep status pending, and return. (linux_resume_one_lwp_throw): Don't call get_pc if thread->while_stepping isn't NULL. Don't call get_thread_regcache if proc->tdesc is NULL. (need_step_over_p): Return 0 if proc->tdesc is NULL. (linux_target_ops): Install arch_setup. * server.c (start_inferior): Call the_target->arch_setup. * target.h (struct target_ops) <arch_setup>: New field. (target_arch_setup): New marco. * lynx-low.c (lynx_target_ops): Update. * nto-low.c (nto_target_ops): Update. * spu-low.c (spu_target_ops): Update. * win32-low.c (win32_target_ops): Update.
2015-07-24 15:40:34 +02:00
struct process_info *proc = get_thread_process (thread);
/* Note that target description may not be initialised
(proc->tdesc == NULL) at this point because the program hasn't
stopped at the first instruction yet. It means GDBserver skips
the extra traps from the wrapper program (see option --wrapper).
Code in this function that requires register access should be
guarded by proc->tdesc == NULL or something else. */
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
Rename "process" to "lwp" throughout. * linux-low.c (all_processes): Rename to... (all_lwps): ... this. (inferior_pid, handle_extended_wait, get_stop_pc): Adjust. (add_process): Rename to ... (add_lwp): ... this. Adjust. (linux_create_inferior): Adjust. (linux_attach_lwp): Adjust. (linux_attach): Adjust. (linux_kill_one_process): Rename to ... (linux_kill_one_lwp): ... this. Adjust. (linux_kill): Adjust. (linux_detach_one_process): Rename to ... (linux_detach_one_lwp): ... this. Adjust. (linux_detach): Adjust. (check_removed_breakpoint): Adjust. (status_pending_p): Adjust. (linux_wait_for_process): Rename to ... (linux_wait_for_lwp): ... this. Adjust. (linux_wait_for_event): Adjust. (send_sigstop): Adjust. (wait_for_sigstop): Adjust. (stop_all_processes): Rename to ... (stop_all_lwps): ... this. (linux_resume_one_process): Rename to ... (linux_resume_one_lwp): ... this. Adjust. (linux_set_resume_request, linux_continue_one_thread) (linux_queue_one_thread, resume_status_pending_p) (usr_store_inferior_registers, regsets_store_inferior_registers) (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Adjust. * linux-low.h (get_process): Rename to ... (get_lwp): ... this. Adjust. (get_thread_process): Rename to ... (get_thread_lwp): ... this. Adjust. (get_process_thread): Rename to ... (get_lwp_thread): ... this. Adjust. (struct process_info): Rename to ... (struct lwp_info): ... this. (all_processes): Rename to ... (all_lwps): ... this. * proc-service.c (ps_lgetregs): Adjust. * thread-db.c (thread_db_create_event, find_one_thread) (maybe_attach_thread, thread_db_get_tls_address): Adjust.
2009-03-17 21:25:35 +01:00
if (lwp->stopped == 0)
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
return;
Remote thread create/exit events When testing with "maint set target-non-stop on", a few threading-related tests expose an issue that requires new RSP packets. Say there are 3 threads running, 1-3. If GDB tries to stop thread 1, 2 and 3, and then waits for their stops, but meanwhile say, thread 2 exits, GDB hangs forever waiting for a stop for thread 2 that won't ever happen. This patch fixes the issue by adding support for thread exit events to the protocol. However, we don't want these always enabled, as they're useless most of the time, and would slow down remote debugging. So I made it so that GDB can enable/disable them, and then made gdb do that around the cases that need it, which currently is only infrun.c:stop_all_threads. In turn, if we have thread exit events, then the extra "thread x exited" traffic slows down attach-many-short-lived-threads.exp enough that gdb has trouble keeping up with new threads that are spawned while gdb tries to stop existing ones. To fix that I added support for the counterpart thread created events too. Enabling those when we try to stop threads ensures that new threads never get a chance to themselves start new threads, killing the race. gdb/doc/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): List "set/show remote thread-events" command in configuration table. (Stop Reply Packets): Document "T05 create" stop reason and 'w' stop reply. (General Query Packets): Document QThreadEvents packet. Document QThreadEvents qSupported feature. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. If GDB wants to hear about thread create events, leave the new child's status pending. (linux_low_filter_event): If GDB wants to hear about thread exit events, leave the LWP marked dead and don't delete it. (linux_wait_for_event_filtered): Don't check for thread exit. (filter_exit_event): New function. (linux_wait_1): Use it, when returning an exit event. (linux_resume_one_lwp_throw): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. * remote-utils.c (prepare_resume_reply): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.c (report_thread_events): New global. (handle_general_set): Handle QThreadEvents. (handle_query) <qSupported>: Handle and report QThreadEvents+; (handle_target_event): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.h (report_thread_events): Declare. gdb/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * NEWS (New commands): Mention "set/show remote thread-events" commands. (New remote packets): Mention thread created/exited stop reasons and QThreadEvents packet. * infrun.c (disable_thread_events): New function. (stop_all_threads): Disable/enable thread create/exit events. Handle TARGET_WAITKIND_THREAD_EXITED. (handle_inferior_event_1): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * remote.c (remove_child_of_pending_fork): Also remove threads of threads that have TARGET_WAITKIND_THREAD_EXITED events. (remote_parse_stop_reply): Handle "create" magic register. Handle 'w' stop reply. (initialize_remote): Install remote_thread_events as to_thread_events target hook. (remote_thread_events): New function. * target-delegates.c: Regenerate. * target.c (target_thread_events): New function. * target.h (struct target_ops) <to_thread_events>: New field. (target_thread_events): Declare. * target/waitstatus.c (target_waitstatus_to_string): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * target/waitstatus.h (enum target_waitkind) <TARGET_WAITKIND_THREAD_CREATED, TARGET_WAITKIND_THREAD_EXITED): New values.
2015-11-30 17:05:21 +01:00
gdb_assert (lwp->waitstatus.kind == TARGET_WAITKIND_IGNORE);
fast_tpoint_collect_result fast_tp_collecting
= lwp->collecting_fast_tracepoint;
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
gdb_assert (!stabilizing_threads
|| (fast_tp_collecting
!= fast_tpoint_collect_result::not_collecting));
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
gdb/gdbserver/ * server.h (LONGEST): New. (struct thread_info) <while_stepping>: New field. (unpack_varlen_hex, xrealloc, pulongest, plongest, phex_nz): Declare. (initialize_tracepoint, handle_tracepoint_general_set) (handle_tracepoint_query, tracepoint_finished_step) (tracepoint_was_hit, release_while_stepping_state_list): (current_traceframe): Declare. * server.c (handle_general_set): Handle tracepoint packets. (read_memory): New. (write_memory): New. (handle_search_memory_1): Use read_memory. (handle_query): Report support for conditional tracepoints, trace state variables, and tracepoint sources. Handle tracepoint queries. (main): Initialize the tracepoints module. (process_serial_event): Handle traceframe reads/writes. * linux-low.c (handle_tracepoints): New. (linux_wait_1): Call it. (linux_resume_one_lwp): Handle while-stepping. (linux_supports_tracepoints, linux_read_pc, linux_write_pc): New. (linux_target_ops): Install them. * linux-low.h (struct linux_target_ops) <supports_tracepoints>: New field. * linux-x86-low.c (x86_supports_tracepoints): New. (the_low_target). Install it. * mem-break.h (delete_breakpoint): Declare. * mem-break.c (delete_breakpoint): Make external. * target.h (struct target_ops): Add `supports_tracepoints', `read_pc', and `write_pc' fields. (target_supports_tracepoints): Define. * utils.c (xrealloc, decimal2str, pulongest, plongest, thirty_two) (phex_nz): New. * regcache.h (struct regcache) <registers_owned>: New field. (init_register_cache, regcache_cpy): Declare. (regcache_read_pc, regcache_write_pc): Declare. (register_cache_size): Declare. (supply_regblock): Declare. * regcache.c (init_register_cache): New. (new_register_cache): Use it. (regcache_cpy): New. (register_cache_size): New. (supply_regblock): New. (regcache_read_pc, regcache_write_pc): New. * tracepoint.c: New. * Makefile.in (OBS): Add tracepoint.o. (tracepoint.o): New rule. gdb/ * regformats/regdat.sh: Include server.h. Don't include regcache.h.
2010-04-09 05:40:00 +02:00
/* Cancel actions that rely on GDB not changing the PC (e.g., the
user used the "jump" command, or "set $pc = foo"). */
Initialise target descrption after skipping extra traps for --wrapper Nowadays, when --wrapper is used, GDBserver skips extra traps/stops in the wrapper program, and stops at the first instruction of the program to be debugged. However, GDBserver created target description in the first stop of inferior, and the executable of the inferior is the wrapper program rather than the program to be debugged. In this way, the target description can be wrong if the architectures of wrapper program and program to be debugged are different. This is shown by some fails in gdb.server/wrapper.exp on buildbot. We are testing i686-linux GDB (Fedora-i686) on an x86_64-linux box (fedora-x86-64-4) in buildbot, such configuration causes fails in gdb.server/wrapper.exp like this: spawn /home/gdb-buildbot-2/fedora-x86-64-4/fedora-i686/build/gdb/testsuite/../../gdb/gdbserver/gdbserver --once --wrapper env TEST=1 -- :2346 /home/gdb-buildbot-2/fedora-x86-64-4/fedora-i686/build/gdb/testsuite/outputs/gdb.server/wrapper/wrapper Process /home/gdb-buildbot-2/fedora-x86-64-4/fedora-i686/build/gdb/testsuite/outputs/gdb.server/wrapper/wrapper created; pid = 8795 Can't debug 64-bit process with 32-bit GDBserver Exiting target remote localhost:2346 localhost:2346: Connection timed out. (gdb) FAIL: gdb.server/wrapper.exp: setting breakpoint at marker See https://sourceware.org/ml/gdb-testers/2015-q3/msg01541.html In this case, program to be debugged ("wrapper") is 32-bit but wrapper program ("/usr/bin/env") is 64-bit, so GDBserver gets the 64-bit target description instead of 32-bit. The root cause of this problem is that GDBserver creates target description too early, and the rationale of fix could be creating target description once the GDBserver skips extra traps and inferior stops at the first instruction of the program we want to debug. IOW, when GDBserver skips extra traps, the inferior's tdesc is NULL, and mywait and its callees shouldn't use inferior's tdesc, so in this patch, we skip code that requires register access, see changes in linux_resume_one_lwp_throw and need_step_over_p. In linux_low_filter_event, if target description isn't initialised and GDBserver attached the process, we create target description immediately, because GDBserver don't have to skip extra traps for attach, IOW, it makes no sense to use --attach and --wrapper together. Otherwise, the process is launched by GDBserver, we keep the status pending, and return. After GDBserver skipped extra traps in start_inferior, we call a target_ops hook arch_setup to initialise target description there. gdb/gdbserver: 2015-07-24 Yao Qi <yao.qi@linaro.org> * linux-low.c (linux_arch_setup): New function. (linux_low_filter_event): If proc->tdesc is NULL and proc->attached is true, call the_low_target.arch_setup. Otherwise, keep status pending, and return. (linux_resume_one_lwp_throw): Don't call get_pc if thread->while_stepping isn't NULL. Don't call get_thread_regcache if proc->tdesc is NULL. (need_step_over_p): Return 0 if proc->tdesc is NULL. (linux_target_ops): Install arch_setup. * server.c (start_inferior): Call the_target->arch_setup. * target.h (struct target_ops) <arch_setup>: New field. (target_arch_setup): New marco. * lynx-low.c (lynx_target_ops): Update. * nto-low.c (nto_target_ops): Update. * spu-low.c (spu_target_ops): Update. * win32-low.c (win32_target_ops): Update.
2015-07-24 15:40:34 +02:00
if (thread->while_stepping != NULL && lwp->stop_pc != get_pc (lwp))
gdb/gdbserver/ * server.h (LONGEST): New. (struct thread_info) <while_stepping>: New field. (unpack_varlen_hex, xrealloc, pulongest, plongest, phex_nz): Declare. (initialize_tracepoint, handle_tracepoint_general_set) (handle_tracepoint_query, tracepoint_finished_step) (tracepoint_was_hit, release_while_stepping_state_list): (current_traceframe): Declare. * server.c (handle_general_set): Handle tracepoint packets. (read_memory): New. (write_memory): New. (handle_search_memory_1): Use read_memory. (handle_query): Report support for conditional tracepoints, trace state variables, and tracepoint sources. Handle tracepoint queries. (main): Initialize the tracepoints module. (process_serial_event): Handle traceframe reads/writes. * linux-low.c (handle_tracepoints): New. (linux_wait_1): Call it. (linux_resume_one_lwp): Handle while-stepping. (linux_supports_tracepoints, linux_read_pc, linux_write_pc): New. (linux_target_ops): Install them. * linux-low.h (struct linux_target_ops) <supports_tracepoints>: New field. * linux-x86-low.c (x86_supports_tracepoints): New. (the_low_target). Install it. * mem-break.h (delete_breakpoint): Declare. * mem-break.c (delete_breakpoint): Make external. * target.h (struct target_ops): Add `supports_tracepoints', `read_pc', and `write_pc' fields. (target_supports_tracepoints): Define. * utils.c (xrealloc, decimal2str, pulongest, plongest, thirty_two) (phex_nz): New. * regcache.h (struct regcache) <registers_owned>: New field. (init_register_cache, regcache_cpy): Declare. (regcache_read_pc, regcache_write_pc): Declare. (register_cache_size): Declare. (supply_regblock): Declare. * regcache.c (init_register_cache): New. (new_register_cache): Use it. (regcache_cpy): New. (register_cache_size): New. (supply_regblock): New. (regcache_read_pc, regcache_write_pc): New. * tracepoint.c: New. * Makefile.in (OBS): Add tracepoint.o. (tracepoint.o): New rule. gdb/ * regformats/regdat.sh: Include server.h. Don't include regcache.h.
2010-04-09 05:40:00 +02:00
{
/* Collecting 'while-stepping' actions doesn't make sense
anymore. */
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
release_while_stepping_state_list (thread);
gdb/gdbserver/ * server.h (LONGEST): New. (struct thread_info) <while_stepping>: New field. (unpack_varlen_hex, xrealloc, pulongest, plongest, phex_nz): Declare. (initialize_tracepoint, handle_tracepoint_general_set) (handle_tracepoint_query, tracepoint_finished_step) (tracepoint_was_hit, release_while_stepping_state_list): (current_traceframe): Declare. * server.c (handle_general_set): Handle tracepoint packets. (read_memory): New. (write_memory): New. (handle_search_memory_1): Use read_memory. (handle_query): Report support for conditional tracepoints, trace state variables, and tracepoint sources. Handle tracepoint queries. (main): Initialize the tracepoints module. (process_serial_event): Handle traceframe reads/writes. * linux-low.c (handle_tracepoints): New. (linux_wait_1): Call it. (linux_resume_one_lwp): Handle while-stepping. (linux_supports_tracepoints, linux_read_pc, linux_write_pc): New. (linux_target_ops): Install them. * linux-low.h (struct linux_target_ops) <supports_tracepoints>: New field. * linux-x86-low.c (x86_supports_tracepoints): New. (the_low_target). Install it. * mem-break.h (delete_breakpoint): Declare. * mem-break.c (delete_breakpoint): Make external. * target.h (struct target_ops): Add `supports_tracepoints', `read_pc', and `write_pc' fields. (target_supports_tracepoints): Define. * utils.c (xrealloc, decimal2str, pulongest, plongest, thirty_two) (phex_nz): New. * regcache.h (struct regcache) <registers_owned>: New field. (init_register_cache, regcache_cpy): Declare. (regcache_read_pc, regcache_write_pc): Declare. (register_cache_size): Declare. (supply_regblock): Declare. * regcache.c (init_register_cache): New. (new_register_cache): Use it. (regcache_cpy): New. (register_cache_size): New. (supply_regblock): New. (regcache_read_pc, regcache_write_pc): New. * tracepoint.c: New. * Makefile.in (OBS): Add tracepoint.o. (tracepoint.o): New rule. gdb/ * regformats/regdat.sh: Include server.h. Don't include regcache.h.
2010-04-09 05:40:00 +02:00
}
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
/* If we have pending signals or status, and a new signal, enqueue the
signal. Also enqueue the signal if it can't be delivered to the
inferior right now. */
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
if (signal != 0
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
&& (lwp->status_pending_p
gdbserver/linux-low: use std::list to store pending signals Use std::list to store pending signals instead of a manually-managed linked list. This is a refactoring. In the existing code, pending signals are kept in a manually-created linked list with "prev" pointers. A new pending signal is thus inserted to the beginning of the list. When consuming, GDB goes until the end of the list, following the "prev" pointers, and processes the final item. With this patch, a new item is added to the end of the list and the item at the front of the list is consumed. In other words, the list elements used to be stored in reverse order; with this patch, they are stored in their order of arrival. This causes a change in the debug messages that print the pending signals. Otherwise, no behavioral change is expected. gdbserver/ChangeLog: 2020-06-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Use std::list to stop pending signal instead of manually-created linked list. * linux-low.h: Include <list>. (struct pending_signal): Move here from linux-low.cc. (struct lwp_info) <pending_signals> <pending_signals_to_report>: Update the type. * linux-low.cc (struct pending_signals): Remove. (linux_process_target::delete_lwp) (linux_process_target::add_lwp) (enqueue_one_deferred_signal) (dequeue_one_deferred_signal) (enqueue_pending_signal) (linux_process_target::resume_one_lwp_throw) (linux_process_target::thread_needs_step_over) (linux_process_target::resume_one_thread) (linux_process_target::proceed_one_lwp): Update the use of pending signal list.
2020-06-22 14:13:48 +02:00
|| !lwp->pending_signals.empty ()
|| !lwp_signal_can_be_delivered (lwp)))
{
enqueue_pending_signal (lwp, signal, info);
/* Postpone any pending signal. It was enqueued above. */
signal = 0;
}
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
if (lwp->status_pending_p)
{
if (debug_threads)
debug_printf ("Not resuming lwp %ld (%s, stop %s);"
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
" has pending status\n",
lwpid_of (thread), step ? "step" : "continue",
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
lwp->stop_expected ? "expected" : "not expected");
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
return;
}
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
saved_thread = current_thread;
current_thread = thread;
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
/* This bit needs some thinking about. If we get a signal that
we must report while a single-step reinsert is still pending,
we often end up resuming the thread. It might be better to
(ew) allow a stack of pending events; then we could be sure that
the reinsert happened right away and not lose any signals.
Making this stack would also shrink the window in which breakpoints are
Rename "process" to "lwp" throughout. * linux-low.c (all_processes): Rename to... (all_lwps): ... this. (inferior_pid, handle_extended_wait, get_stop_pc): Adjust. (add_process): Rename to ... (add_lwp): ... this. Adjust. (linux_create_inferior): Adjust. (linux_attach_lwp): Adjust. (linux_attach): Adjust. (linux_kill_one_process): Rename to ... (linux_kill_one_lwp): ... this. Adjust. (linux_kill): Adjust. (linux_detach_one_process): Rename to ... (linux_detach_one_lwp): ... this. Adjust. (linux_detach): Adjust. (check_removed_breakpoint): Adjust. (status_pending_p): Adjust. (linux_wait_for_process): Rename to ... (linux_wait_for_lwp): ... this. Adjust. (linux_wait_for_event): Adjust. (send_sigstop): Adjust. (wait_for_sigstop): Adjust. (stop_all_processes): Rename to ... (stop_all_lwps): ... this. (linux_resume_one_process): Rename to ... (linux_resume_one_lwp): ... this. Adjust. (linux_set_resume_request, linux_continue_one_thread) (linux_queue_one_thread, resume_status_pending_p) (usr_store_inferior_registers, regsets_store_inferior_registers) (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Adjust. * linux-low.h (get_process): Rename to ... (get_lwp): ... this. Adjust. (get_thread_process): Rename to ... (get_thread_lwp): ... this. Adjust. (get_process_thread): Rename to ... (get_lwp_thread): ... this. Adjust. (struct process_info): Rename to ... (struct lwp_info): ... this. (all_processes): Rename to ... (all_lwps): ... this. * proc-service.c (ps_lgetregs): Adjust. * thread-db.c (thread_db_create_event, find_one_thread) (maybe_attach_thread, thread_db_get_tls_address): Adjust.
2009-03-17 21:25:35 +01:00
uninserted (see comment in linux_wait_for_lwp) but not enough for
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
complete correctness, so it won't solve that problem. It may be
worthwhile just to solve this one, however. */
Rename "process" to "lwp" throughout. * linux-low.c (all_processes): Rename to... (all_lwps): ... this. (inferior_pid, handle_extended_wait, get_stop_pc): Adjust. (add_process): Rename to ... (add_lwp): ... this. Adjust. (linux_create_inferior): Adjust. (linux_attach_lwp): Adjust. (linux_attach): Adjust. (linux_kill_one_process): Rename to ... (linux_kill_one_lwp): ... this. Adjust. (linux_kill): Adjust. (linux_detach_one_process): Rename to ... (linux_detach_one_lwp): ... this. Adjust. (linux_detach): Adjust. (check_removed_breakpoint): Adjust. (status_pending_p): Adjust. (linux_wait_for_process): Rename to ... (linux_wait_for_lwp): ... this. Adjust. (linux_wait_for_event): Adjust. (send_sigstop): Adjust. (wait_for_sigstop): Adjust. (stop_all_processes): Rename to ... (stop_all_lwps): ... this. (linux_resume_one_process): Rename to ... (linux_resume_one_lwp): ... this. Adjust. (linux_set_resume_request, linux_continue_one_thread) (linux_queue_one_thread, resume_status_pending_p) (usr_store_inferior_registers, regsets_store_inferior_registers) (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Adjust. * linux-low.h (get_process): Rename to ... (get_lwp): ... this. Adjust. (get_thread_process): Rename to ... (get_thread_lwp): ... this. Adjust. (get_process_thread): Rename to ... (get_lwp_thread): ... this. Adjust. (struct process_info): Rename to ... (struct lwp_info): ... this. (all_processes): Rename to ... (all_lwps): ... this. * proc-service.c (ps_lgetregs): Adjust. * thread-db.c (thread_db_create_event, find_one_thread) (maybe_attach_thread, thread_db_get_tls_address): Adjust.
2009-03-17 21:25:35 +01:00
if (lwp->bp_reinsert != 0)
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf (" pending reinsert at 0x%s\n",
paddress (lwp->bp_reinsert));
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
gdbserver/linux-low: turn 'supports_hardware_single_step' into a method All the linux low targets except arm define the 'supports_hardware_single_step' op to return true. Hence, we override the method to return true in linux_process_target, and remove the definitions in all the linux low targets but arm. gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Remove the 'supports_hardware_single_step' linux target op and override the process_stratum_target's op definition in linux_process_target to return true. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <finish_step_over> <maybe_hw_step>: Declare. * linux-low.cc (can_hardware_single_step): Remove. (maybe_hw_step): Turn into... (linux_process_target::maybe_hw_step): ...this. (finish_step_over): Turn into... (linux_process_target::finish_step_over): ...this. (linux_process_target::supports_hardware_single_step): Update to return true. Update the callers below. (linux_process_target::single_step) (linux_process_target::resume_one_lwp_throw) * linux-arm-low.cc (class arm_target) <supports_hardware_single_step>: Declare. (arm_supports_hardware_single_step): Turn into... (arm_target::supports_hardware_single_step): ...this. (the_low_target): Remove the op field. * linux-x86-low.cc (x86_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-aarch64-low.cc (aarch64_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-bfin-low.cc (bfin_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-crisv32-low.cc (cris_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-m32r-low.cc (m32r_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-m68k-low.cc (m68k_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-ppc-low.cc (ppc_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-s390-low.cc (s390_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-sh-low.cc (sh_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-tic6x-low.cc (tic6x_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-tile-low.cc (tile_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-xtensa-low.cc (xtensa_supports_hardware_single_step): Remove. (the_low_target): Remove the op field.
2020-04-02 15:11:31 +02:00
if (supports_hardware_single_step ())
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
{
if (fast_tp_collecting == fast_tpoint_collect_result::not_collecting)
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
{
if (step == 0)
warning ("BAD - reinserting but not stepping.");
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
if (lwp->suspended)
warning ("BAD - reinserting and suspended(%d).",
lwp->suspended);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
}
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
}
Switch to current thread in finish_step_over This patch adds some sanity check that reinsert breakpoints must be there when doing step-over on software single step target. The check triggers an assert when running forking-threads-plus-breakpoint.exp on arm-linux target, gdb/gdbserver/linux-low.c:4714: A problem internal to GDBserver has been detected.^M int finish_step_over(lwp_info*): Assertion `has_reinsert_breakpoints ()' failed. the error happens when GDBserver has already resumed a thread of process A for step-over (and wait for it hitting reinsert breakpoint), but receives detach request for process B from GDB, which is shown in the backtrace below, (gdb) bt #2 0x000228aa in finish_step_over (lwp=0x12bbd98) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4703 #3 0x00025a50 in finish_step_over (lwp=0x12bbd98) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4749 #4 complete_ongoing_step_over () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4760 #5 linux_detach (pid=25228) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:1503 #6 0x00012bae in process_serial_event () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3974 #7 handle_serial_event (err=<optimized out>, client_data=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:4347 #8 0x00016d68 in handle_file_event (event_file_desc=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:429 #9 0x000173ea in process_event () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:184 #10 start_event_loop () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:547 #11 0x0000aa2c in captured_main (argv=<optimized out>, argc=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3719 #12 main (argc=<optimized out>, argv=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3804 the sanity check tries to find the reinsert breakpoint from process B, but nothing is found. It is wrong, we need to search in process A, since we started step-over of a thread of process A. (gdb) p lwp->thread->entry.id $3 = {pid = 25120, lwp = 25131, tid = 0} (gdb) p current_thread->entry.id $4 = {pid = 25228, lwp = 25228, tid = 0} This patch switched current_thread to the thread we are doing step-over in finish_step_over. gdb/gdbserver: 2016-06-17 Yao Qi <yao.qi@linaro.org> * linux-low.c (maybe_hw_step): New function. (linux_resume_one_lwp_throw): Call maybe_hw_step. (finish_step_over): Switch current_thread to lwp temporarily, and assert has_reinsert_breakpoints returns true. (proceed_one_lwp): Call maybe_hw_step. * mem-break.c (has_reinsert_breakpoints): New function. * mem-break.h (has_reinsert_breakpoints): Declare.
2016-06-17 11:25:12 +02:00
step = maybe_hw_step (thread);
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
}
if (fast_tp_collecting == fast_tpoint_collect_result::before_insn)
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("lwp %ld wants to get out of fast tracepoint jump pad"
" (exit-jump-pad-bkpt)\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
lwpid_of (thread));
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
}
else if (fast_tp_collecting == fast_tpoint_collect_result::at_insn)
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("lwp %ld wants to get out of fast tracepoint jump pad"
" single-stepping\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
lwpid_of (thread));
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
gdbserver/linux-low: turn 'supports_hardware_single_step' into a method All the linux low targets except arm define the 'supports_hardware_single_step' op to return true. Hence, we override the method to return true in linux_process_target, and remove the definitions in all the linux low targets but arm. gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Remove the 'supports_hardware_single_step' linux target op and override the process_stratum_target's op definition in linux_process_target to return true. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <finish_step_over> <maybe_hw_step>: Declare. * linux-low.cc (can_hardware_single_step): Remove. (maybe_hw_step): Turn into... (linux_process_target::maybe_hw_step): ...this. (finish_step_over): Turn into... (linux_process_target::finish_step_over): ...this. (linux_process_target::supports_hardware_single_step): Update to return true. Update the callers below. (linux_process_target::single_step) (linux_process_target::resume_one_lwp_throw) * linux-arm-low.cc (class arm_target) <supports_hardware_single_step>: Declare. (arm_supports_hardware_single_step): Turn into... (arm_target::supports_hardware_single_step): ...this. (the_low_target): Remove the op field. * linux-x86-low.cc (x86_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-aarch64-low.cc (aarch64_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-bfin-low.cc (bfin_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-crisv32-low.cc (cris_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-m32r-low.cc (m32r_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-m68k-low.cc (m68k_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-ppc-low.cc (ppc_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-s390-low.cc (s390_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-sh-low.cc (sh_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-tic6x-low.cc (tic6x_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-tile-low.cc (tile_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-xtensa-low.cc (xtensa_supports_hardware_single_step): Remove. (the_low_target): Remove the op field.
2020-04-02 15:11:31 +02:00
if (supports_hardware_single_step ())
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
step = 1;
else
{
internal_error (__FILE__, __LINE__,
"moving out of jump pad single-stepping"
" not implemented on this target");
}
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
}
gdb/gdbserver/ * server.h (LONGEST): New. (struct thread_info) <while_stepping>: New field. (unpack_varlen_hex, xrealloc, pulongest, plongest, phex_nz): Declare. (initialize_tracepoint, handle_tracepoint_general_set) (handle_tracepoint_query, tracepoint_finished_step) (tracepoint_was_hit, release_while_stepping_state_list): (current_traceframe): Declare. * server.c (handle_general_set): Handle tracepoint packets. (read_memory): New. (write_memory): New. (handle_search_memory_1): Use read_memory. (handle_query): Report support for conditional tracepoints, trace state variables, and tracepoint sources. Handle tracepoint queries. (main): Initialize the tracepoints module. (process_serial_event): Handle traceframe reads/writes. * linux-low.c (handle_tracepoints): New. (linux_wait_1): Call it. (linux_resume_one_lwp): Handle while-stepping. (linux_supports_tracepoints, linux_read_pc, linux_write_pc): New. (linux_target_ops): Install them. * linux-low.h (struct linux_target_ops) <supports_tracepoints>: New field. * linux-x86-low.c (x86_supports_tracepoints): New. (the_low_target). Install it. * mem-break.h (delete_breakpoint): Declare. * mem-break.c (delete_breakpoint): Make external. * target.h (struct target_ops): Add `supports_tracepoints', `read_pc', and `write_pc' fields. (target_supports_tracepoints): Define. * utils.c (xrealloc, decimal2str, pulongest, plongest, thirty_two) (phex_nz): New. * regcache.h (struct regcache) <registers_owned>: New field. (init_register_cache, regcache_cpy): Declare. (regcache_read_pc, regcache_write_pc): Declare. (register_cache_size): Declare. (supply_regblock): Declare. * regcache.c (init_register_cache): New. (new_register_cache): Use it. (regcache_cpy): New. (register_cache_size): New. (supply_regblock): New. (regcache_read_pc, regcache_write_pc): New. * tracepoint.c: New. * Makefile.in (OBS): Add tracepoint.o. (tracepoint.o): New rule. gdb/ * regformats/regdat.sh: Include server.h. Don't include regcache.h.
2010-04-09 05:40:00 +02:00
/* If we have while-stepping actions in this thread set it stepping.
If we have a signal to deliver, it may or may not be set to
SIG_IGN, we don't know. Assume so, and allow collecting
while-stepping into a signal handler. A possible smart thing to
do would be to set an internal breakpoint at the signal return
address, continue, and carry on catching this while-stepping
action only when that breakpoint is hit. A future
enhancement. */
if (thread->while_stepping != NULL)
gdb/gdbserver/ * server.h (LONGEST): New. (struct thread_info) <while_stepping>: New field. (unpack_varlen_hex, xrealloc, pulongest, plongest, phex_nz): Declare. (initialize_tracepoint, handle_tracepoint_general_set) (handle_tracepoint_query, tracepoint_finished_step) (tracepoint_was_hit, release_while_stepping_state_list): (current_traceframe): Declare. * server.c (handle_general_set): Handle tracepoint packets. (read_memory): New. (write_memory): New. (handle_search_memory_1): Use read_memory. (handle_query): Report support for conditional tracepoints, trace state variables, and tracepoint sources. Handle tracepoint queries. (main): Initialize the tracepoints module. (process_serial_event): Handle traceframe reads/writes. * linux-low.c (handle_tracepoints): New. (linux_wait_1): Call it. (linux_resume_one_lwp): Handle while-stepping. (linux_supports_tracepoints, linux_read_pc, linux_write_pc): New. (linux_target_ops): Install them. * linux-low.h (struct linux_target_ops) <supports_tracepoints>: New field. * linux-x86-low.c (x86_supports_tracepoints): New. (the_low_target). Install it. * mem-break.h (delete_breakpoint): Declare. * mem-break.c (delete_breakpoint): Make external. * target.h (struct target_ops): Add `supports_tracepoints', `read_pc', and `write_pc' fields. (target_supports_tracepoints): Define. * utils.c (xrealloc, decimal2str, pulongest, plongest, thirty_two) (phex_nz): New. * regcache.h (struct regcache) <registers_owned>: New field. (init_register_cache, regcache_cpy): Declare. (regcache_read_pc, regcache_write_pc): Declare. (register_cache_size): Declare. (supply_regblock): Declare. * regcache.c (init_register_cache): New. (new_register_cache): Use it. (regcache_cpy): New. (register_cache_size): New. (supply_regblock): New. (regcache_read_pc, regcache_write_pc): New. * tracepoint.c: New. * Makefile.in (OBS): Add tracepoint.o. (tracepoint.o): New rule. gdb/ * regformats/regdat.sh: Include server.h. Don't include regcache.h.
2010-04-09 05:40:00 +02:00
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("lwp %ld has a while-stepping action -> forcing step.\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
lwpid_of (thread));
step = single_step (lwp);
gdb/gdbserver/ * server.h (LONGEST): New. (struct thread_info) <while_stepping>: New field. (unpack_varlen_hex, xrealloc, pulongest, plongest, phex_nz): Declare. (initialize_tracepoint, handle_tracepoint_general_set) (handle_tracepoint_query, tracepoint_finished_step) (tracepoint_was_hit, release_while_stepping_state_list): (current_traceframe): Declare. * server.c (handle_general_set): Handle tracepoint packets. (read_memory): New. (write_memory): New. (handle_search_memory_1): Use read_memory. (handle_query): Report support for conditional tracepoints, trace state variables, and tracepoint sources. Handle tracepoint queries. (main): Initialize the tracepoints module. (process_serial_event): Handle traceframe reads/writes. * linux-low.c (handle_tracepoints): New. (linux_wait_1): Call it. (linux_resume_one_lwp): Handle while-stepping. (linux_supports_tracepoints, linux_read_pc, linux_write_pc): New. (linux_target_ops): Install them. * linux-low.h (struct linux_target_ops) <supports_tracepoints>: New field. * linux-x86-low.c (x86_supports_tracepoints): New. (the_low_target). Install it. * mem-break.h (delete_breakpoint): Declare. * mem-break.c (delete_breakpoint): Make external. * target.h (struct target_ops): Add `supports_tracepoints', `read_pc', and `write_pc' fields. (target_supports_tracepoints): Define. * utils.c (xrealloc, decimal2str, pulongest, plongest, thirty_two) (phex_nz): New. * regcache.h (struct regcache) <registers_owned>: New field. (init_register_cache, regcache_cpy): Declare. (regcache_read_pc, regcache_write_pc): Declare. (register_cache_size): Declare. (supply_regblock): Declare. * regcache.c (init_register_cache): New. (new_register_cache): Use it. (regcache_cpy): New. (register_cache_size): New. (supply_regblock): New. (regcache_read_pc, regcache_write_pc): New. * tracepoint.c: New. * Makefile.in (OBS): Add tracepoint.o. (tracepoint.o): New rule. gdb/ * regformats/regdat.sh: Include server.h. Don't include regcache.h.
2010-04-09 05:40:00 +02:00
}
gdbserver/linux-low: turn 'get_pc' and 'set_pc' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_pc' and 'set_pc' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. * linux-low.cc (supports_breakpoints): Turn into... (linux_process_target::low_supports_breakpoints): ...this. (linux_process_target::low_get_pc): Define. (linux_process_target::low_set_pc): Define. Update the callers below. (linux_process_target::get_pc) (linux_process_target::save_stop_reason) (linux_process_target::maybe_move_out_of_jump_pad) (linux_process_target::wait_1) (linux_process_target::resume_one_lwp_throw) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (linux_process_target::read_pc) (linux_process_target::write_pc) * linux-x86-low.cc (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (x86_target::low_supports_breakpoints): Define. (x86_get_pc): Turn into... (x86_target::low_get_pc): ...this. (x86_set_pc): Turn into... (x86_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (arm_target::low_supports_breakpoints) (arm_target::low_get_pc) (arm_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (bfin_target::low_supports_breakpoints) (bfin_target::low_get_pc) (bfin_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (cris_target::low_supports_breakpoints) (cris_target::low_get_pc) (cris_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (crisv32_target::low_supports_breakpoints) (crisv32_target::low_get_pc) (crisv32_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m32r_target::low_supports_breakpoints) (m32r_target::low_get_pc) (m32r_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m68k_target::low_supports_breakpoints) (m68k_target::low_get_pc) (m68k_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (nios2_target::low_supports_breakpoints) (nios2_target::low_get_pc) (nios2_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (sh_target::low_supports_breakpoints) (sh_target::low_get_pc) (sh_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (xtensa_target::low_supports_breakpoints) (xtensa_target::low_get_pc) (xtensa_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_supports_breakpoints> <low_get_pc>: Declare. (sparc_target::low_supports_breakpoints) (sparc_target::low_get_pc): Define. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tile_target::low_supports_breakpoints) (tile_target::low_get_pc) (tile_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (aarch64_target::low_supports_breakpoints): Define. (aarch64_get_pc): Turn into... (aarch64_target::low_get_pc): ...this. (aarch64_set_pc): Turn into... (aarch64_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (mips_target::low_supports_breakpoints): Define. (mips_get_pc): Turn into... (mips_target::low_get_pc): ...this. (mips_set_pc): Turn into... (mips_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (ppc_target::low_supports_breakpoints): Define. (ppc_get_pc): Turn into... (ppc_target::low_get_pc): ...this. (ppc_set_pc): Turn into... (ppc_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (riscv_target::low_supports_breakpoints): Define. (riscv_get_pc): Turn into... (riscv_target::low_get_pc): ...this. (riscv_set_pc): Turn into... (riscv_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (s390_target::low_supports_breakpoints): Define. (s390_get_pc): Turn into... (s390_target::low_get_pc): ...this. (s390_set_pc): Turn into... (s390_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tic6x_target::low_supports_breakpoints): Define. (tic6x_get_pc): Turn into... (tic6x_target::low_get_pc): ...this. (tic6x_set_pc): Turn into... (tic6x_target::low_set_pc): ...this. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
if (proc->tdesc != NULL && low_supports_breakpoints ())
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
{
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
struct regcache *regcache = get_thread_regcache (current_thread, 1);
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
gdbserver/linux-low: turn 'get_pc' and 'set_pc' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_pc' and 'set_pc' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. * linux-low.cc (supports_breakpoints): Turn into... (linux_process_target::low_supports_breakpoints): ...this. (linux_process_target::low_get_pc): Define. (linux_process_target::low_set_pc): Define. Update the callers below. (linux_process_target::get_pc) (linux_process_target::save_stop_reason) (linux_process_target::maybe_move_out_of_jump_pad) (linux_process_target::wait_1) (linux_process_target::resume_one_lwp_throw) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (linux_process_target::read_pc) (linux_process_target::write_pc) * linux-x86-low.cc (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (x86_target::low_supports_breakpoints): Define. (x86_get_pc): Turn into... (x86_target::low_get_pc): ...this. (x86_set_pc): Turn into... (x86_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (arm_target::low_supports_breakpoints) (arm_target::low_get_pc) (arm_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (bfin_target::low_supports_breakpoints) (bfin_target::low_get_pc) (bfin_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (cris_target::low_supports_breakpoints) (cris_target::low_get_pc) (cris_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (crisv32_target::low_supports_breakpoints) (crisv32_target::low_get_pc) (crisv32_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m32r_target::low_supports_breakpoints) (m32r_target::low_get_pc) (m32r_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m68k_target::low_supports_breakpoints) (m68k_target::low_get_pc) (m68k_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (nios2_target::low_supports_breakpoints) (nios2_target::low_get_pc) (nios2_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (sh_target::low_supports_breakpoints) (sh_target::low_get_pc) (sh_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (xtensa_target::low_supports_breakpoints) (xtensa_target::low_get_pc) (xtensa_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_supports_breakpoints> <low_get_pc>: Declare. (sparc_target::low_supports_breakpoints) (sparc_target::low_get_pc): Define. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tile_target::low_supports_breakpoints) (tile_target::low_get_pc) (tile_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (aarch64_target::low_supports_breakpoints): Define. (aarch64_get_pc): Turn into... (aarch64_target::low_get_pc): ...this. (aarch64_set_pc): Turn into... (aarch64_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (mips_target::low_supports_breakpoints): Define. (mips_get_pc): Turn into... (mips_target::low_get_pc): ...this. (mips_set_pc): Turn into... (mips_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (ppc_target::low_supports_breakpoints): Define. (ppc_get_pc): Turn into... (ppc_target::low_get_pc): ...this. (ppc_set_pc): Turn into... (ppc_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (riscv_target::low_supports_breakpoints): Define. (riscv_get_pc): Turn into... (riscv_target::low_get_pc): ...this. (riscv_set_pc): Turn into... (riscv_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (s390_target::low_supports_breakpoints): Define. (s390_get_pc): Turn into... (s390_target::low_get_pc): ...this. (s390_set_pc): Turn into... (s390_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tic6x_target::low_supports_breakpoints): Define. (tic6x_get_pc): Turn into... (tic6x_target::low_get_pc): ...this. (tic6x_set_pc): Turn into... (tic6x_target::low_set_pc): ...this. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
lwp->stop_pc = low_get_pc (regcache);
[gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too This patch applies the same starvation avoidance improvements of the previous patch to the Linux gdbserver side. Without this, the test added by the following commit (gdb.threads/non-stop-fair-events.exp) always fails with time outs. gdb/gdbserver/ 2015-01-09 Pedro Alves <palves@redhat.com> * linux-low.c (step_over_bkpt): Move higher up in the file. (handle_extended_wait): Don't store the stop_pc here. (get_stop_pc): Adjust comments and rename to ... (check_stopped_by_breakpoint): ... this. Record whether the LWP stopped for a software breakpoint or hardware breakpoint. (thread_still_has_status_pending_p): New function. (status_pending_p_callback): Use thread_still_has_status_pending_p. If the event is no longer interesting, resume the LWP. (handle_tracepoints): Add assert. (maybe_move_out_of_jump_pad): Remove cancel_breakpoints call. (wstatus_maybe_breakpoint): New function. (cancel_breakpoint): Delete function. (check_stopped_by_watchpoint): New function, factored out from linux_low_filter_event. (lp_status_maybe_breakpoint): Delete function. (linux_low_filter_event): Remove filter_ptid argument. Leave thread group exits pending here. Store the LWP's stop PC. Always leave events pending. (linux_wait_for_event_filtered): Pull all events out of the kernel, and leave them all pending. (count_events_callback, select_event_lwp_callback): Consider all events. (cancel_breakpoints_callback, linux_cancel_breakpoints): Delete. (select_event_lwp): Only give preference to the stepping LWP in all-stop mode. Adjust comments. (ignore_event): New function. (linux_wait_1): Delete 'retry' label. Use ignore_event. Remove references to cancel_breakpoints. Adjust to renames. Also give equal priority to all LWPs that have had events in non-stop mode. If reporting a software breakpoint event, unadjust the LWP's PC. (linux_wait): If linux_wait_1 returned an ignored event, retry. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Adjust. (linux_resume_one_lwp): Store the LWP's PC. Adjust. (resume_status_pending_p): Use thread_still_has_status_pending_p. (linux_stopped_by_watchpoint): Adjust. (linux_target_ops): Remove reference to linux_cancel_breakpoints. * linux-low.h (enum lwp_stop_reason): New. (struct lwp_info) <stop_pc>: Adjust comment. <stopped_by_watchpoint>: Delete field. <stop_reason>: New field. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. * mem-break.c (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): New function. * mem-break.h (software_breakpoint_inserted_here) (hardware_breakpoint_inserted_here): Declare. * target.h (struct target_ops) <cancel_breakpoints>: Remove field. (cancel_breakpoints): Delete. * tracepoint.c (clear_installed_tracepoints, stop_tracing) (upload_fast_traceframes): Remove references to cancel_breakpoints.
2014-12-29 20:41:07 +01:00
if (debug_threads)
{
debug_printf (" %s from pc 0x%lx\n", step ? "step" : "continue",
(long) lwp->stop_pc);
}
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
}
/* If we have pending signals, consume one if it can be delivered to
the inferior. */
gdbserver/linux-low: use std::list to store pending signals Use std::list to store pending signals instead of a manually-managed linked list. This is a refactoring. In the existing code, pending signals are kept in a manually-created linked list with "prev" pointers. A new pending signal is thus inserted to the beginning of the list. When consuming, GDB goes until the end of the list, following the "prev" pointers, and processes the final item. With this patch, a new item is added to the end of the list and the item at the front of the list is consumed. In other words, the list elements used to be stored in reverse order; with this patch, they are stored in their order of arrival. This causes a change in the debug messages that print the pending signals. Otherwise, no behavioral change is expected. gdbserver/ChangeLog: 2020-06-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Use std::list to stop pending signal instead of manually-created linked list. * linux-low.h: Include <list>. (struct pending_signal): Move here from linux-low.cc. (struct lwp_info) <pending_signals> <pending_signals_to_report>: Update the type. * linux-low.cc (struct pending_signals): Remove. (linux_process_target::delete_lwp) (linux_process_target::add_lwp) (enqueue_one_deferred_signal) (dequeue_one_deferred_signal) (enqueue_pending_signal) (linux_process_target::resume_one_lwp_throw) (linux_process_target::thread_needs_step_over) (linux_process_target::resume_one_thread) (linux_process_target::proceed_one_lwp): Update the use of pending signal list.
2020-06-22 14:13:48 +02:00
if (!lwp->pending_signals.empty () && lwp_signal_can_be_delivered (lwp))
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
{
gdbserver/linux-low: use std::list to store pending signals Use std::list to store pending signals instead of a manually-managed linked list. This is a refactoring. In the existing code, pending signals are kept in a manually-created linked list with "prev" pointers. A new pending signal is thus inserted to the beginning of the list. When consuming, GDB goes until the end of the list, following the "prev" pointers, and processes the final item. With this patch, a new item is added to the end of the list and the item at the front of the list is consumed. In other words, the list elements used to be stored in reverse order; with this patch, they are stored in their order of arrival. This causes a change in the debug messages that print the pending signals. Otherwise, no behavioral change is expected. gdbserver/ChangeLog: 2020-06-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Use std::list to stop pending signal instead of manually-created linked list. * linux-low.h: Include <list>. (struct pending_signal): Move here from linux-low.cc. (struct lwp_info) <pending_signals> <pending_signals_to_report>: Update the type. * linux-low.cc (struct pending_signals): Remove. (linux_process_target::delete_lwp) (linux_process_target::add_lwp) (enqueue_one_deferred_signal) (dequeue_one_deferred_signal) (enqueue_pending_signal) (linux_process_target::resume_one_lwp_throw) (linux_process_target::thread_needs_step_over) (linux_process_target::resume_one_thread) (linux_process_target::proceed_one_lwp): Update the use of pending signal list.
2020-06-22 14:13:48 +02:00
const pending_signal &p_sig = lwp->pending_signals.front ();
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
gdbserver/linux-low: use std::list to store pending signals Use std::list to store pending signals instead of a manually-managed linked list. This is a refactoring. In the existing code, pending signals are kept in a manually-created linked list with "prev" pointers. A new pending signal is thus inserted to the beginning of the list. When consuming, GDB goes until the end of the list, following the "prev" pointers, and processes the final item. With this patch, a new item is added to the end of the list and the item at the front of the list is consumed. In other words, the list elements used to be stored in reverse order; with this patch, they are stored in their order of arrival. This causes a change in the debug messages that print the pending signals. Otherwise, no behavioral change is expected. gdbserver/ChangeLog: 2020-06-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Use std::list to stop pending signal instead of manually-created linked list. * linux-low.h: Include <list>. (struct pending_signal): Move here from linux-low.cc. (struct lwp_info) <pending_signals> <pending_signals_to_report>: Update the type. * linux-low.cc (struct pending_signals): Remove. (linux_process_target::delete_lwp) (linux_process_target::add_lwp) (enqueue_one_deferred_signal) (dequeue_one_deferred_signal) (enqueue_pending_signal) (linux_process_target::resume_one_lwp_throw) (linux_process_target::thread_needs_step_over) (linux_process_target::resume_one_thread) (linux_process_target::proceed_one_lwp): Update the use of pending signal list.
2020-06-22 14:13:48 +02:00
signal = p_sig.signal;
if (p_sig.info.si_signo != 0)
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
ptrace (PTRACE_SETSIGINFO, lwpid_of (thread), (PTRACE_TYPE_ARG3) 0,
gdbserver/linux-low: use std::list to store pending signals Use std::list to store pending signals instead of a manually-managed linked list. This is a refactoring. In the existing code, pending signals are kept in a manually-created linked list with "prev" pointers. A new pending signal is thus inserted to the beginning of the list. When consuming, GDB goes until the end of the list, following the "prev" pointers, and processes the final item. With this patch, a new item is added to the end of the list and the item at the front of the list is consumed. In other words, the list elements used to be stored in reverse order; with this patch, they are stored in their order of arrival. This causes a change in the debug messages that print the pending signals. Otherwise, no behavioral change is expected. gdbserver/ChangeLog: 2020-06-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Use std::list to stop pending signal instead of manually-created linked list. * linux-low.h: Include <list>. (struct pending_signal): Move here from linux-low.cc. (struct lwp_info) <pending_signals> <pending_signals_to_report>: Update the type. * linux-low.cc (struct pending_signals): Remove. (linux_process_target::delete_lwp) (linux_process_target::add_lwp) (enqueue_one_deferred_signal) (dequeue_one_deferred_signal) (enqueue_pending_signal) (linux_process_target::resume_one_lwp_throw) (linux_process_target::thread_needs_step_over) (linux_process_target::resume_one_thread) (linux_process_target::proceed_one_lwp): Update the use of pending signal list.
2020-06-22 14:13:48 +02:00
&p_sig.info);
gdbserver/linux-low: use std::list to store pending signals Use std::list to store pending signals instead of a manually-managed linked list. This is a refactoring. In the existing code, pending signals are kept in a manually-created linked list with "prev" pointers. A new pending signal is thus inserted to the beginning of the list. When consuming, GDB goes until the end of the list, following the "prev" pointers, and processes the final item. With this patch, a new item is added to the end of the list and the item at the front of the list is consumed. In other words, the list elements used to be stored in reverse order; with this patch, they are stored in their order of arrival. This causes a change in the debug messages that print the pending signals. Otherwise, no behavioral change is expected. gdbserver/ChangeLog: 2020-06-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Use std::list to stop pending signal instead of manually-created linked list. * linux-low.h: Include <list>. (struct pending_signal): Move here from linux-low.cc. (struct lwp_info) <pending_signals> <pending_signals_to_report>: Update the type. * linux-low.cc (struct pending_signals): Remove. (linux_process_target::delete_lwp) (linux_process_target::add_lwp) (enqueue_one_deferred_signal) (dequeue_one_deferred_signal) (enqueue_pending_signal) (linux_process_target::resume_one_lwp_throw) (linux_process_target::thread_needs_step_over) (linux_process_target::resume_one_thread) (linux_process_target::proceed_one_lwp): Update the use of pending signal list.
2020-06-22 14:13:48 +02:00
lwp->pending_signals.pop_front ();
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
}
if (debug_threads)
debug_printf ("Resuming lwp %ld (%s, signal %d, stop %s)\n",
lwpid_of (thread), step ? "step" : "continue", signal,
lwp->stop_expected ? "expected" : "not expected");
gdbserver/linux-low: turn 'prepare_to_resume' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'prepare_to_resume' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <low_prepare_to_resume>: Declare. * linux-low.cc (linux_process_target::low_prepare_to_resume): Define. Update the callers below: (linux_process_target::resume_one_lwp_throw) (linux_process_target::low_prepare_to_resume) * linux-x86-low.cc (class x86_target) <low_prepare_to_resume>: Declare. (x86_target::low_prepare_to_resume): Define. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <low_prepare_to_resume>: Declare. (aarch64_target::low_prepare_to_resume): Define. (the_low_target): Remove the op field. * linux-arm-low.cc (class arm_target) <low_prepare_to_resume>: Declare. (arm_prepare_to_resume): Turn into... (arm_target::low_prepare_to_resume): ...this. (the_low_target): Remove the op field. * linux-mips-low.cc (class mips_target) <low_prepare_to_resume>: Declare. (mips_linux_prepare_to_resume): Turn into... (mips_target::low_prepare_to_resume): ...this. (the_low_target): Remove the op field. * linux-bfin-low.cc (the_low_target): Remove the op field. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:29 +02:00
low_prepare_to_resume (lwp);
Add h/w watchpoint support to x86-linux, win32-i386. * Makefile.in (SFILES): Add i386-low.c (i386_low_h): Define. (i386-low.o): Add dependencies. (linux-x86-low.o): Add i386-low.h dependency. (win32-i386-low.o): Ditto. * i386-low.c: New file. * i386-low.h: New file. * configure.srv (i[34567]86-*-cygwin*): Add i386-low.o to srv_tgtobj. (i[34567]86-*-linux*, i[34567]86-*-mingw*, x86_64-*-linux*): Ditto. * linux-low.c (linux_add_process): Initialize arch_private. (linux_remove_process): Free arch_private. (add_lwp): Initialize arch_private. (delete_lwp): Free arch_private. (linux_resume_one_lwp): Call the_low_target.prepare_to_resume if provided. * linux-low.h (process_info_private): New member arch_private. (lwp_info): New member arch_private. (linux_target_ops): New members new_process, new_thread, prepare_to_resume. (ptid_of): New macro. * linux-x86-low.c: Include stddef.h, i386-low.h. (arch_process_info): New struct. (arch_lwp_info): New struct. (x86_linux_dr_get, x86_linux_dr_set): New functions. (i386_dr_low_set_addr, i386_dr_low_set_control): New functions. (i386_dr_low_get_status): New function. (x86_insert_point, x86_remove_point): New functions. (x86_stopped_by_watchpoint): New function. (x86_stopped_data_address): New function. (x86_linux_new_process, x86_linux_new_thread): New functions. (x86_linux_prepare_to_resume): New function. (the_low_target): Add entries for insert_point, remove_point, stopped_by_watchpoint, stopped_data_address, new_process, new_thread, prepare_to_resume. * server.c (debug_hw_points): New global. (monitor_show_help): Document set debug-hw-points. (handle_query): Process "set debug-hw-points". * server.h (debug_hw_points): Declare. (paddress): Declare. * utils.c (NUMCELLS, CELLSIZE): New macros. (get_sell, xsnprintf, paddress): New functions. * win32-arm-low.c (the_low_target): Add entries for insert_point, remove_point, stopped_by_watchpoint, stopped_data_address. * win32-i386-low.c: Include i386-low.h. (debug_reg_state): Replaces dr. (i386_dr_low_set_addr, i386_dr_low_set_control): New functions. (i386_dr_low_get_status): New function. (i386_insert_point, i386_remove_point): New functions. (i386_stopped_by_watchpoint): New function. (i386_stopped_data_address): New function. (i386_initial_stuff): Update. (get_thread_context,set_thread_context,i386_thread_added): Update. (the_low_target): Add entries for insert_point, remove_point, stopped_by_watchpoint, stopped_data_address. * win32-low.c (win32_insert_watchpoint): New function. (win32_remove_watchpoint): New function. (win32_stopped_by_watchpoint): New function. (win32_stopped_data_address): New function. (win32_target_ops): Add entries for insert_watchpoint, remove_watchpoint, stopped_by_watchpoint, stopped_data_address. * win32-low.h (win32_target_ops): New members insert_point, remove_point, stopped_by_watchpoint, stopped_data_address.
2009-06-30 18:35:25 +02:00
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
regcache_invalidate_thread (thread);
errno = 0;
Rename "process" to "lwp" throughout. * linux-low.c (all_processes): Rename to... (all_lwps): ... this. (inferior_pid, handle_extended_wait, get_stop_pc): Adjust. (add_process): Rename to ... (add_lwp): ... this. Adjust. (linux_create_inferior): Adjust. (linux_attach_lwp): Adjust. (linux_attach): Adjust. (linux_kill_one_process): Rename to ... (linux_kill_one_lwp): ... this. Adjust. (linux_kill): Adjust. (linux_detach_one_process): Rename to ... (linux_detach_one_lwp): ... this. Adjust. (linux_detach): Adjust. (check_removed_breakpoint): Adjust. (status_pending_p): Adjust. (linux_wait_for_process): Rename to ... (linux_wait_for_lwp): ... this. Adjust. (linux_wait_for_event): Adjust. (send_sigstop): Adjust. (wait_for_sigstop): Adjust. (stop_all_processes): Rename to ... (stop_all_lwps): ... this. (linux_resume_one_process): Rename to ... (linux_resume_one_lwp): ... this. Adjust. (linux_set_resume_request, linux_continue_one_thread) (linux_queue_one_thread, resume_status_pending_p) (usr_store_inferior_registers, regsets_store_inferior_registers) (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Adjust. * linux-low.h (get_process): Rename to ... (get_lwp): ... this. Adjust. (get_thread_process): Rename to ... (get_thread_lwp): ... this. Adjust. (get_process_thread): Rename to ... (get_lwp_thread): ... this. Adjust. (struct process_info): Rename to ... (struct lwp_info): ... this. (all_processes): Rename to ... (all_lwps): ... this. * proc-service.c (ps_lgetregs): Adjust. * thread-db.c (thread_db_create_event, find_one_thread) (maybe_attach_thread, thread_db_get_tls_address): Adjust.
2009-03-17 21:25:35 +01:00
lwp->stepping = step;
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
if (step)
ptrace_request = PTRACE_SINGLESTEP;
else if (gdb_catching_syscalls_p (lwp))
ptrace_request = PTRACE_SYSCALL;
else
ptrace_request = PTRACE_CONT;
ptrace (ptrace_request,
lwpid_of (thread),
(PTRACE_TYPE_ARG3) 0,
/* Coerce to a uintptr_t first to avoid potential gcc warning
of coercing an 8 byte integer to a 4 byte pointer. */
(PTRACE_TYPE_ARG4) (uintptr_t) signal);
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
current_thread = saved_thread;
if (errno)
Fix race exposed by gdb.threads/killed.exp On GNU/Linux, this test sometimes FAILs like this: (gdb) run Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/killed [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". ptrace: No such process. (gdb) Program terminated with signal SIGKILL, Killed. The program no longer exists. FAIL: gdb.threads/killed.exp: run program to completion (timeout) Note the suspicious "No such process" line (that's errno==ESRCH). Adding debug output we see: linux_nat_wait: [process -1], [TARGET_WNOHANG] LLW: enter LNW: waitpid(-1, ...) returned 18465, ERRNO-OK LLW: waitpid 18465 received Stopped (signal) (stopped) LNW: waitpid(-1, ...) returned 18461, ERRNO-OK LLW: waitpid 18461 received Trace/breakpoint trap (stopped) LLW: Handling extended status 0x03057f LHEW: Got clone event from LWP 18461, new child is LWP 18465 LNW: waitpid(-1, ...) returned 0, ERRNO-OK RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0 RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0 sigchld ptrace: No such process. (gdb) linux_nat_wait: [process -1], [TARGET_WNOHANG] LLW: enter LNW: waitpid(-1, ...) returned 18465, ERRNO-OK LLW: waitpid 18465 received Killed (terminated) LLW: LWP 18465 exited. LNW: waitpid(-1, ...) returned 18461, No child processes LLW: waitpid 18461 received Killed (terminated) Process 18461 exited LNW: waitpid(-1, ...) returned -1, No child processes LLW: exit sigchld infrun: target_wait (-1, status) = infrun: 18461 [process 18461], infrun: status->kind = signalled, signal = GDB_SIGNAL_KILL infrun: TARGET_WAITKIND_SIGNALLED Program terminated with signal SIGKILL, Killed. The program no longer exists. infrun: stop_waiting FAIL: gdb.threads/killed.exp: run program to completion (timeout) The issue is that here: RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0 RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0 The first line shows we had just resumed LWP 18465, which does: void * child_func (void *dummy) { kill (pid, SIGKILL); exit (1); } So if the kernel manages to schedule that thread fast enough, the process may be killed before GDB has a chance to resume LWP 18461. GDBserver has code at the tail end of linux_resume_one_lwp to cope with this: ~~~ ptrace (step ? PTRACE_SINGLESTEP : PTRACE_CONT, lwpid_of (thread), (PTRACE_TYPE_ARG3) 0, /* Coerce to a uintptr_t first to avoid potential gcc warning of coercing an 8 byte integer to a 4 byte pointer. */ (PTRACE_TYPE_ARG4) (uintptr_t) signal); current_thread = saved_thread; if (errno) { /* ESRCH from ptrace either means that the thread was already running (an error) or that it is gone (a race condition). If it's gone, we will get a notification the next time we wait, so we can ignore the error. We could differentiate these two, but it's tricky without waiting; the thread still exists as a zombie, so sending it signal 0 would succeed. So just ignore ESRCH. */ if (errno == ESRCH) return; perror_with_name ("ptrace"); } ~~~ However, that's not a complete fix, because between starting to handle the resume request and getting that PTRACE_CONTINUE, we run other ptrace calls that can also fail with ESRCH, and that end up throwing an error (with perror_with_name). In the case above, I indeed sometimes see resume_stopped_resumed_lwps fail in the registers read: resume_stopped_resumed_lwps (struct lwp_info *lp, void *data) { ... CORE_ADDR pc = regcache_read_pc (regcache); Or e.g., in 32-bit mode, i386_linux_resume has several calls that can throw too. Whether to ignore ptrace errors or not depends on context that is only available somewhere up the call chain. So the fix is to let ptrace errors throw as they do today, and wrap the resume request in a TRY/CATCH that swallows it iff the lwp that we were trying to resume is no longer ptrace-stopped. gdb/gdbserver/ChangeLog: 2015-03-19 Pedro Alves <palves@redhat.com> * linux-low.c (linux_resume_one_lwp): Rename to ... (linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here, instead call perror_with_name. (check_ptrace_stopped_lwp_gone): New function. (linux_resume_one_lwp): Reimplement as wrapper around linux_resume_one_lwp_throw that swallows errors if the LWP is gone. gdb/ChangeLog: 2015-03-19 Pedro Alves <palves@redhat.com> * linux-nat.c (linux_resume_one_lwp): Rename to ... (linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here, instead call perror_with_name. (check_ptrace_stopped_lwp_gone): New function. (linux_resume_one_lwp): Reimplement as wrapper around linux_resume_one_lwp_throw that swallows errors if the LWP is gone. (resume_stopped_resumed_lwps): Try register reads in TRY/CATCH and swallows errors if the LWP is gone. Use linux_resume_one_lwp_throw instead of linux_resume_one_lwp.
2015-03-19 16:12:33 +01:00
perror_with_name ("resuming thread");
/* Successfully resumed. Clear state that no longer makes sense,
and mark the LWP as running. Must not do this before resuming
otherwise if that fails other code will be confused. E.g., we'd
later try to stop the LWP and hang forever waiting for a stop
status. Note that we must not throw after this is cleared,
otherwise handle_zombie_lwp_error would get confused. */
lwp->stopped = 0;
lwp->stop_reason = TARGET_STOPPED_BY_NO_REASON;
}
gdbserver/linux-low: turn 'prepare_to_resume' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'prepare_to_resume' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <low_prepare_to_resume>: Declare. * linux-low.cc (linux_process_target::low_prepare_to_resume): Define. Update the callers below: (linux_process_target::resume_one_lwp_throw) (linux_process_target::low_prepare_to_resume) * linux-x86-low.cc (class x86_target) <low_prepare_to_resume>: Declare. (x86_target::low_prepare_to_resume): Define. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <low_prepare_to_resume>: Declare. (aarch64_target::low_prepare_to_resume): Define. (the_low_target): Remove the op field. * linux-arm-low.cc (class arm_target) <low_prepare_to_resume>: Declare. (arm_prepare_to_resume): Turn into... (arm_target::low_prepare_to_resume): ...this. (the_low_target): Remove the op field. * linux-mips-low.cc (class mips_target) <low_prepare_to_resume>: Declare. (mips_linux_prepare_to_resume): Turn into... (mips_target::low_prepare_to_resume): ...this. (the_low_target): Remove the op field. * linux-bfin-low.cc (the_low_target): Remove the op field. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:29 +02:00
void
linux_process_target::low_prepare_to_resume (lwp_info *lwp)
{
/* Nop. */
}
Fix race exposed by gdb.threads/killed.exp On GNU/Linux, this test sometimes FAILs like this: (gdb) run Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/killed [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". ptrace: No such process. (gdb) Program terminated with signal SIGKILL, Killed. The program no longer exists. FAIL: gdb.threads/killed.exp: run program to completion (timeout) Note the suspicious "No such process" line (that's errno==ESRCH). Adding debug output we see: linux_nat_wait: [process -1], [TARGET_WNOHANG] LLW: enter LNW: waitpid(-1, ...) returned 18465, ERRNO-OK LLW: waitpid 18465 received Stopped (signal) (stopped) LNW: waitpid(-1, ...) returned 18461, ERRNO-OK LLW: waitpid 18461 received Trace/breakpoint trap (stopped) LLW: Handling extended status 0x03057f LHEW: Got clone event from LWP 18461, new child is LWP 18465 LNW: waitpid(-1, ...) returned 0, ERRNO-OK RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0 RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0 sigchld ptrace: No such process. (gdb) linux_nat_wait: [process -1], [TARGET_WNOHANG] LLW: enter LNW: waitpid(-1, ...) returned 18465, ERRNO-OK LLW: waitpid 18465 received Killed (terminated) LLW: LWP 18465 exited. LNW: waitpid(-1, ...) returned 18461, No child processes LLW: waitpid 18461 received Killed (terminated) Process 18461 exited LNW: waitpid(-1, ...) returned -1, No child processes LLW: exit sigchld infrun: target_wait (-1, status) = infrun: 18461 [process 18461], infrun: status->kind = signalled, signal = GDB_SIGNAL_KILL infrun: TARGET_WAITKIND_SIGNALLED Program terminated with signal SIGKILL, Killed. The program no longer exists. infrun: stop_waiting FAIL: gdb.threads/killed.exp: run program to completion (timeout) The issue is that here: RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0 RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0 The first line shows we had just resumed LWP 18465, which does: void * child_func (void *dummy) { kill (pid, SIGKILL); exit (1); } So if the kernel manages to schedule that thread fast enough, the process may be killed before GDB has a chance to resume LWP 18461. GDBserver has code at the tail end of linux_resume_one_lwp to cope with this: ~~~ ptrace (step ? PTRACE_SINGLESTEP : PTRACE_CONT, lwpid_of (thread), (PTRACE_TYPE_ARG3) 0, /* Coerce to a uintptr_t first to avoid potential gcc warning of coercing an 8 byte integer to a 4 byte pointer. */ (PTRACE_TYPE_ARG4) (uintptr_t) signal); current_thread = saved_thread; if (errno) { /* ESRCH from ptrace either means that the thread was already running (an error) or that it is gone (a race condition). If it's gone, we will get a notification the next time we wait, so we can ignore the error. We could differentiate these two, but it's tricky without waiting; the thread still exists as a zombie, so sending it signal 0 would succeed. So just ignore ESRCH. */ if (errno == ESRCH) return; perror_with_name ("ptrace"); } ~~~ However, that's not a complete fix, because between starting to handle the resume request and getting that PTRACE_CONTINUE, we run other ptrace calls that can also fail with ESRCH, and that end up throwing an error (with perror_with_name). In the case above, I indeed sometimes see resume_stopped_resumed_lwps fail in the registers read: resume_stopped_resumed_lwps (struct lwp_info *lp, void *data) { ... CORE_ADDR pc = regcache_read_pc (regcache); Or e.g., in 32-bit mode, i386_linux_resume has several calls that can throw too. Whether to ignore ptrace errors or not depends on context that is only available somewhere up the call chain. So the fix is to let ptrace errors throw as they do today, and wrap the resume request in a TRY/CATCH that swallows it iff the lwp that we were trying to resume is no longer ptrace-stopped. gdb/gdbserver/ChangeLog: 2015-03-19 Pedro Alves <palves@redhat.com> * linux-low.c (linux_resume_one_lwp): Rename to ... (linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here, instead call perror_with_name. (check_ptrace_stopped_lwp_gone): New function. (linux_resume_one_lwp): Reimplement as wrapper around linux_resume_one_lwp_throw that swallows errors if the LWP is gone. gdb/ChangeLog: 2015-03-19 Pedro Alves <palves@redhat.com> * linux-nat.c (linux_resume_one_lwp): Rename to ... (linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here, instead call perror_with_name. (check_ptrace_stopped_lwp_gone): New function. (linux_resume_one_lwp): Reimplement as wrapper around linux_resume_one_lwp_throw that swallows errors if the LWP is gone. (resume_stopped_resumed_lwps): Try register reads in TRY/CATCH and swallows errors if the LWP is gone. Use linux_resume_one_lwp_throw instead of linux_resume_one_lwp.
2015-03-19 16:12:33 +01:00
/* Called when we try to resume a stopped LWP and that errors out. If
the LWP is no longer in ptrace-stopped state (meaning it's zombie,
or about to become), discard the error, clear any pending status
the LWP may have, and return true (we'll collect the exit status
soon enough). Otherwise, return false. */
static int
check_ptrace_stopped_lwp_gone (struct lwp_info *lp)
{
struct thread_info *thread = get_lwp_thread (lp);
/* If we get an error after resuming the LWP successfully, we'd
confuse !T state for the LWP being gone. */
gdb_assert (lp->stopped);
/* We can't just check whether the LWP is in 'Z (Zombie)' state,
because even if ptrace failed with ESRCH, the tracee may be "not
yet fully dead", but already refusing ptrace requests. In that
case the tracee has 'R (Running)' state for a little bit
(observed in Linux 3.18). See also the note on ESRCH in the
ptrace(2) man page. Instead, check whether the LWP has any state
other than ptrace-stopped. */
/* Don't assume anything if /proc/PID/status can't be read. */
if (linux_proc_pid_is_trace_stopped_nowarn (lwpid_of (thread)) == 0)
{
Fix race exposed by gdb.threads/killed.exp On GNU/Linux, this test sometimes FAILs like this: (gdb) run Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/killed [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". ptrace: No such process. (gdb) Program terminated with signal SIGKILL, Killed. The program no longer exists. FAIL: gdb.threads/killed.exp: run program to completion (timeout) Note the suspicious "No such process" line (that's errno==ESRCH). Adding debug output we see: linux_nat_wait: [process -1], [TARGET_WNOHANG] LLW: enter LNW: waitpid(-1, ...) returned 18465, ERRNO-OK LLW: waitpid 18465 received Stopped (signal) (stopped) LNW: waitpid(-1, ...) returned 18461, ERRNO-OK LLW: waitpid 18461 received Trace/breakpoint trap (stopped) LLW: Handling extended status 0x03057f LHEW: Got clone event from LWP 18461, new child is LWP 18465 LNW: waitpid(-1, ...) returned 0, ERRNO-OK RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0 RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0 sigchld ptrace: No such process. (gdb) linux_nat_wait: [process -1], [TARGET_WNOHANG] LLW: enter LNW: waitpid(-1, ...) returned 18465, ERRNO-OK LLW: waitpid 18465 received Killed (terminated) LLW: LWP 18465 exited. LNW: waitpid(-1, ...) returned 18461, No child processes LLW: waitpid 18461 received Killed (terminated) Process 18461 exited LNW: waitpid(-1, ...) returned -1, No child processes LLW: exit sigchld infrun: target_wait (-1, status) = infrun: 18461 [process 18461], infrun: status->kind = signalled, signal = GDB_SIGNAL_KILL infrun: TARGET_WAITKIND_SIGNALLED Program terminated with signal SIGKILL, Killed. The program no longer exists. infrun: stop_waiting FAIL: gdb.threads/killed.exp: run program to completion (timeout) The issue is that here: RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0 RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0 The first line shows we had just resumed LWP 18465, which does: void * child_func (void *dummy) { kill (pid, SIGKILL); exit (1); } So if the kernel manages to schedule that thread fast enough, the process may be killed before GDB has a chance to resume LWP 18461. GDBserver has code at the tail end of linux_resume_one_lwp to cope with this: ~~~ ptrace (step ? PTRACE_SINGLESTEP : PTRACE_CONT, lwpid_of (thread), (PTRACE_TYPE_ARG3) 0, /* Coerce to a uintptr_t first to avoid potential gcc warning of coercing an 8 byte integer to a 4 byte pointer. */ (PTRACE_TYPE_ARG4) (uintptr_t) signal); current_thread = saved_thread; if (errno) { /* ESRCH from ptrace either means that the thread was already running (an error) or that it is gone (a race condition). If it's gone, we will get a notification the next time we wait, so we can ignore the error. We could differentiate these two, but it's tricky without waiting; the thread still exists as a zombie, so sending it signal 0 would succeed. So just ignore ESRCH. */ if (errno == ESRCH) return; perror_with_name ("ptrace"); } ~~~ However, that's not a complete fix, because between starting to handle the resume request and getting that PTRACE_CONTINUE, we run other ptrace calls that can also fail with ESRCH, and that end up throwing an error (with perror_with_name). In the case above, I indeed sometimes see resume_stopped_resumed_lwps fail in the registers read: resume_stopped_resumed_lwps (struct lwp_info *lp, void *data) { ... CORE_ADDR pc = regcache_read_pc (regcache); Or e.g., in 32-bit mode, i386_linux_resume has several calls that can throw too. Whether to ignore ptrace errors or not depends on context that is only available somewhere up the call chain. So the fix is to let ptrace errors throw as they do today, and wrap the resume request in a TRY/CATCH that swallows it iff the lwp that we were trying to resume is no longer ptrace-stopped. gdb/gdbserver/ChangeLog: 2015-03-19 Pedro Alves <palves@redhat.com> * linux-low.c (linux_resume_one_lwp): Rename to ... (linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here, instead call perror_with_name. (check_ptrace_stopped_lwp_gone): New function. (linux_resume_one_lwp): Reimplement as wrapper around linux_resume_one_lwp_throw that swallows errors if the LWP is gone. gdb/ChangeLog: 2015-03-19 Pedro Alves <palves@redhat.com> * linux-nat.c (linux_resume_one_lwp): Rename to ... (linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here, instead call perror_with_name. (check_ptrace_stopped_lwp_gone): New function. (linux_resume_one_lwp): Reimplement as wrapper around linux_resume_one_lwp_throw that swallows errors if the LWP is gone. (resume_stopped_resumed_lwps): Try register reads in TRY/CATCH and swallows errors if the LWP is gone. Use linux_resume_one_lwp_throw instead of linux_resume_one_lwp.
2015-03-19 16:12:33 +01:00
lp->stop_reason = TARGET_STOPPED_BY_NO_REASON;
lp->status_pending_p = 0;
return 1;
}
return 0;
}
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
void
linux_process_target::resume_one_lwp (lwp_info *lwp, int step, int signal,
siginfo_t *info)
Fix race exposed by gdb.threads/killed.exp On GNU/Linux, this test sometimes FAILs like this: (gdb) run Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/killed [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". ptrace: No such process. (gdb) Program terminated with signal SIGKILL, Killed. The program no longer exists. FAIL: gdb.threads/killed.exp: run program to completion (timeout) Note the suspicious "No such process" line (that's errno==ESRCH). Adding debug output we see: linux_nat_wait: [process -1], [TARGET_WNOHANG] LLW: enter LNW: waitpid(-1, ...) returned 18465, ERRNO-OK LLW: waitpid 18465 received Stopped (signal) (stopped) LNW: waitpid(-1, ...) returned 18461, ERRNO-OK LLW: waitpid 18461 received Trace/breakpoint trap (stopped) LLW: Handling extended status 0x03057f LHEW: Got clone event from LWP 18461, new child is LWP 18465 LNW: waitpid(-1, ...) returned 0, ERRNO-OK RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0 RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0 sigchld ptrace: No such process. (gdb) linux_nat_wait: [process -1], [TARGET_WNOHANG] LLW: enter LNW: waitpid(-1, ...) returned 18465, ERRNO-OK LLW: waitpid 18465 received Killed (terminated) LLW: LWP 18465 exited. LNW: waitpid(-1, ...) returned 18461, No child processes LLW: waitpid 18461 received Killed (terminated) Process 18461 exited LNW: waitpid(-1, ...) returned -1, No child processes LLW: exit sigchld infrun: target_wait (-1, status) = infrun: 18461 [process 18461], infrun: status->kind = signalled, signal = GDB_SIGNAL_KILL infrun: TARGET_WAITKIND_SIGNALLED Program terminated with signal SIGKILL, Killed. The program no longer exists. infrun: stop_waiting FAIL: gdb.threads/killed.exp: run program to completion (timeout) The issue is that here: RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0 RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0 The first line shows we had just resumed LWP 18465, which does: void * child_func (void *dummy) { kill (pid, SIGKILL); exit (1); } So if the kernel manages to schedule that thread fast enough, the process may be killed before GDB has a chance to resume LWP 18461. GDBserver has code at the tail end of linux_resume_one_lwp to cope with this: ~~~ ptrace (step ? PTRACE_SINGLESTEP : PTRACE_CONT, lwpid_of (thread), (PTRACE_TYPE_ARG3) 0, /* Coerce to a uintptr_t first to avoid potential gcc warning of coercing an 8 byte integer to a 4 byte pointer. */ (PTRACE_TYPE_ARG4) (uintptr_t) signal); current_thread = saved_thread; if (errno) { /* ESRCH from ptrace either means that the thread was already running (an error) or that it is gone (a race condition). If it's gone, we will get a notification the next time we wait, so we can ignore the error. We could differentiate these two, but it's tricky without waiting; the thread still exists as a zombie, so sending it signal 0 would succeed. So just ignore ESRCH. */ if (errno == ESRCH) return; perror_with_name ("ptrace"); } ~~~ However, that's not a complete fix, because between starting to handle the resume request and getting that PTRACE_CONTINUE, we run other ptrace calls that can also fail with ESRCH, and that end up throwing an error (with perror_with_name). In the case above, I indeed sometimes see resume_stopped_resumed_lwps fail in the registers read: resume_stopped_resumed_lwps (struct lwp_info *lp, void *data) { ... CORE_ADDR pc = regcache_read_pc (regcache); Or e.g., in 32-bit mode, i386_linux_resume has several calls that can throw too. Whether to ignore ptrace errors or not depends on context that is only available somewhere up the call chain. So the fix is to let ptrace errors throw as they do today, and wrap the resume request in a TRY/CATCH that swallows it iff the lwp that we were trying to resume is no longer ptrace-stopped. gdb/gdbserver/ChangeLog: 2015-03-19 Pedro Alves <palves@redhat.com> * linux-low.c (linux_resume_one_lwp): Rename to ... (linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here, instead call perror_with_name. (check_ptrace_stopped_lwp_gone): New function. (linux_resume_one_lwp): Reimplement as wrapper around linux_resume_one_lwp_throw that swallows errors if the LWP is gone. gdb/ChangeLog: 2015-03-19 Pedro Alves <palves@redhat.com> * linux-nat.c (linux_resume_one_lwp): Rename to ... (linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here, instead call perror_with_name. (check_ptrace_stopped_lwp_gone): New function. (linux_resume_one_lwp): Reimplement as wrapper around linux_resume_one_lwp_throw that swallows errors if the LWP is gone. (resume_stopped_resumed_lwps): Try register reads in TRY/CATCH and swallows errors if the LWP is gone. Use linux_resume_one_lwp_throw instead of linux_resume_one_lwp.
2015-03-19 16:12:33 +01:00
{
Rewrite TRY/CATCH This rewrites gdb's TRY/CATCH to plain C++ try/catch. The patch was largely written by script, though one change (to a comment in common-exceptions.h) was reverted by hand. gdb/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * xml-support.c: Use C++ exception handling. * x86-linux-nat.c: Use C++ exception handling. * windows-nat.c: Use C++ exception handling. * varobj.c: Use C++ exception handling. * value.c: Use C++ exception handling. * valprint.c: Use C++ exception handling. * valops.c: Use C++ exception handling. * unittests/parse-connection-spec-selftests.c: Use C++ exception handling. * unittests/cli-utils-selftests.c: Use C++ exception handling. * typeprint.c: Use C++ exception handling. * tui/tui.c: Use C++ exception handling. * tracefile-tfile.c: Use C++ exception handling. * top.c: Use C++ exception handling. * thread.c: Use C++ exception handling. * target.c: Use C++ exception handling. * symmisc.c: Use C++ exception handling. * symfile-mem.c: Use C++ exception handling. * stack.c: Use C++ exception handling. * sparc64-linux-tdep.c: Use C++ exception handling. * solib.c: Use C++ exception handling. * solib-svr4.c: Use C++ exception handling. * solib-spu.c: Use C++ exception handling. * solib-frv.c: Use C++ exception handling. * solib-dsbt.c: Use C++ exception handling. * selftest-arch.c: Use C++ exception handling. * s390-tdep.c: Use C++ exception handling. * rust-lang.c: Use C++ exception handling. * rust-exp.y: Use C++ exception handling. * rs6000-tdep.c: Use C++ exception handling. * rs6000-aix-tdep.c: Use C++ exception handling. * riscv-tdep.c: Use C++ exception handling. * remote.c: Use C++ exception handling. * remote-fileio.c: Use C++ exception handling. * record-full.c: Use C++ exception handling. * record-btrace.c: Use C++ exception handling. * python/python.c: Use C++ exception handling. * python/py-value.c: Use C++ exception handling. * python/py-utils.c: Use C++ exception handling. * python/py-unwind.c: Use C++ exception handling. * python/py-type.c: Use C++ exception handling. * python/py-symbol.c: Use C++ exception handling. * python/py-record.c: Use C++ exception handling. * python/py-record-btrace.c: Use C++ exception handling. * python/py-progspace.c: Use C++ exception handling. * python/py-prettyprint.c: Use C++ exception handling. * python/py-param.c: Use C++ exception handling. * python/py-objfile.c: Use C++ exception handling. * python/py-linetable.c: Use C++ exception handling. * python/py-lazy-string.c: Use C++ exception handling. * python/py-infthread.c: Use C++ exception handling. * python/py-inferior.c: Use C++ exception handling. * python/py-gdb-readline.c: Use C++ exception handling. * python/py-framefilter.c: Use C++ exception handling. * python/py-frame.c: Use C++ exception handling. * python/py-finishbreakpoint.c: Use C++ exception handling. * python/py-cmd.c: Use C++ exception handling. * python/py-breakpoint.c: Use C++ exception handling. * python/py-arch.c: Use C++ exception handling. * printcmd.c: Use C++ exception handling. * ppc-linux-tdep.c: Use C++ exception handling. * parse.c: Use C++ exception handling. * p-valprint.c: Use C++ exception handling. * objc-lang.c: Use C++ exception handling. * mi/mi-main.c: Use C++ exception handling. * mi/mi-interp.c: Use C++ exception handling. * mi/mi-cmd-stack.c: Use C++ exception handling. * mi/mi-cmd-break.c: Use C++ exception handling. * main.c: Use C++ exception handling. * linux-thread-db.c: Use C++ exception handling. * linux-tdep.c: Use C++ exception handling. * linux-nat.c: Use C++ exception handling. * linux-fork.c: Use C++ exception handling. * linespec.c: Use C++ exception handling. * language.c: Use C++ exception handling. * jit.c: Use C++ exception handling. * infrun.c: Use C++ exception handling. * infcmd.c: Use C++ exception handling. * infcall.c: Use C++ exception handling. * inf-loop.c: Use C++ exception handling. * i386-tdep.c: Use C++ exception handling. * i386-linux-tdep.c: Use C++ exception handling. * guile/scm-value.c: Use C++ exception handling. * guile/scm-type.c: Use C++ exception handling. * guile/scm-symtab.c: Use C++ exception handling. * guile/scm-symbol.c: Use C++ exception handling. * guile/scm-pretty-print.c: Use C++ exception handling. * guile/scm-ports.c: Use C++ exception handling. * guile/scm-param.c: Use C++ exception handling. * guile/scm-math.c: Use C++ exception handling. * guile/scm-lazy-string.c: Use C++ exception handling. * guile/scm-frame.c: Use C++ exception handling. * guile/scm-disasm.c: Use C++ exception handling. * guile/scm-cmd.c: Use C++ exception handling. * guile/scm-breakpoint.c: Use C++ exception handling. * guile/scm-block.c: Use C++ exception handling. * guile/guile-internal.h: Use C++ exception handling. * gnu-v3-abi.c: Use C++ exception handling. * gdbtypes.c: Use C++ exception handling. * frame.c: Use C++ exception handling. * frame-unwind.c: Use C++ exception handling. * fbsd-tdep.c: Use C++ exception handling. * f-valprint.c: Use C++ exception handling. * exec.c: Use C++ exception handling. * event-top.c: Use C++ exception handling. * event-loop.c: Use C++ exception handling. * eval.c: Use C++ exception handling. * dwarf2read.c: Use C++ exception handling. * dwarf2loc.c: Use C++ exception handling. * dwarf2-frame.c: Use C++ exception handling. * dwarf2-frame-tailcall.c: Use C++ exception handling. * dwarf-index-write.c: Use C++ exception handling. * dwarf-index-cache.c: Use C++ exception handling. * dtrace-probe.c: Use C++ exception handling. * disasm-selftests.c: Use C++ exception handling. * darwin-nat.c: Use C++ exception handling. * cp-valprint.c: Use C++ exception handling. * cp-support.c: Use C++ exception handling. * cp-abi.c: Use C++ exception handling. * corelow.c: Use C++ exception handling. * completer.c: Use C++ exception handling. * compile/compile-object-run.c: Use C++ exception handling. * compile/compile-object-load.c: Use C++ exception handling. * compile/compile-cplus-symbols.c: Use C++ exception handling. * compile/compile-c-symbols.c: Use C++ exception handling. * common/selftest.c: Use C++ exception handling. * common/new-op.c: Use C++ exception handling. * cli/cli-script.c: Use C++ exception handling. * cli/cli-interp.c: Use C++ exception handling. * cli/cli-cmds.c: Use C++ exception handling. * c-varobj.c: Use C++ exception handling. * btrace.c: Use C++ exception handling. * breakpoint.c: Use C++ exception handling. * break-catch-throw.c: Use C++ exception handling. * arch-utils.c: Use C++ exception handling. * amd64-tdep.c: Use C++ exception handling. * ada-valprint.c: Use C++ exception handling. * ada-typeprint.c: Use C++ exception handling. * ada-lang.c: Use C++ exception handling. * aarch64-tdep.c: Use C++ exception handling. gdb/gdbserver/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * server.c: Use C++ exception handling. * linux-low.c: Use C++ exception handling. * gdbreplay.c: Use C++ exception handling.
2019-04-04 00:02:42 +02:00
try
Fix race exposed by gdb.threads/killed.exp On GNU/Linux, this test sometimes FAILs like this: (gdb) run Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/killed [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". ptrace: No such process. (gdb) Program terminated with signal SIGKILL, Killed. The program no longer exists. FAIL: gdb.threads/killed.exp: run program to completion (timeout) Note the suspicious "No such process" line (that's errno==ESRCH). Adding debug output we see: linux_nat_wait: [process -1], [TARGET_WNOHANG] LLW: enter LNW: waitpid(-1, ...) returned 18465, ERRNO-OK LLW: waitpid 18465 received Stopped (signal) (stopped) LNW: waitpid(-1, ...) returned 18461, ERRNO-OK LLW: waitpid 18461 received Trace/breakpoint trap (stopped) LLW: Handling extended status 0x03057f LHEW: Got clone event from LWP 18461, new child is LWP 18465 LNW: waitpid(-1, ...) returned 0, ERRNO-OK RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0 RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0 sigchld ptrace: No such process. (gdb) linux_nat_wait: [process -1], [TARGET_WNOHANG] LLW: enter LNW: waitpid(-1, ...) returned 18465, ERRNO-OK LLW: waitpid 18465 received Killed (terminated) LLW: LWP 18465 exited. LNW: waitpid(-1, ...) returned 18461, No child processes LLW: waitpid 18461 received Killed (terminated) Process 18461 exited LNW: waitpid(-1, ...) returned -1, No child processes LLW: exit sigchld infrun: target_wait (-1, status) = infrun: 18461 [process 18461], infrun: status->kind = signalled, signal = GDB_SIGNAL_KILL infrun: TARGET_WAITKIND_SIGNALLED Program terminated with signal SIGKILL, Killed. The program no longer exists. infrun: stop_waiting FAIL: gdb.threads/killed.exp: run program to completion (timeout) The issue is that here: RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0 RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0 The first line shows we had just resumed LWP 18465, which does: void * child_func (void *dummy) { kill (pid, SIGKILL); exit (1); } So if the kernel manages to schedule that thread fast enough, the process may be killed before GDB has a chance to resume LWP 18461. GDBserver has code at the tail end of linux_resume_one_lwp to cope with this: ~~~ ptrace (step ? PTRACE_SINGLESTEP : PTRACE_CONT, lwpid_of (thread), (PTRACE_TYPE_ARG3) 0, /* Coerce to a uintptr_t first to avoid potential gcc warning of coercing an 8 byte integer to a 4 byte pointer. */ (PTRACE_TYPE_ARG4) (uintptr_t) signal); current_thread = saved_thread; if (errno) { /* ESRCH from ptrace either means that the thread was already running (an error) or that it is gone (a race condition). If it's gone, we will get a notification the next time we wait, so we can ignore the error. We could differentiate these two, but it's tricky without waiting; the thread still exists as a zombie, so sending it signal 0 would succeed. So just ignore ESRCH. */ if (errno == ESRCH) return; perror_with_name ("ptrace"); } ~~~ However, that's not a complete fix, because between starting to handle the resume request and getting that PTRACE_CONTINUE, we run other ptrace calls that can also fail with ESRCH, and that end up throwing an error (with perror_with_name). In the case above, I indeed sometimes see resume_stopped_resumed_lwps fail in the registers read: resume_stopped_resumed_lwps (struct lwp_info *lp, void *data) { ... CORE_ADDR pc = regcache_read_pc (regcache); Or e.g., in 32-bit mode, i386_linux_resume has several calls that can throw too. Whether to ignore ptrace errors or not depends on context that is only available somewhere up the call chain. So the fix is to let ptrace errors throw as they do today, and wrap the resume request in a TRY/CATCH that swallows it iff the lwp that we were trying to resume is no longer ptrace-stopped. gdb/gdbserver/ChangeLog: 2015-03-19 Pedro Alves <palves@redhat.com> * linux-low.c (linux_resume_one_lwp): Rename to ... (linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here, instead call perror_with_name. (check_ptrace_stopped_lwp_gone): New function. (linux_resume_one_lwp): Reimplement as wrapper around linux_resume_one_lwp_throw that swallows errors if the LWP is gone. gdb/ChangeLog: 2015-03-19 Pedro Alves <palves@redhat.com> * linux-nat.c (linux_resume_one_lwp): Rename to ... (linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here, instead call perror_with_name. (check_ptrace_stopped_lwp_gone): New function. (linux_resume_one_lwp): Reimplement as wrapper around linux_resume_one_lwp_throw that swallows errors if the LWP is gone. (resume_stopped_resumed_lwps): Try register reads in TRY/CATCH and swallows errors if the LWP is gone. Use linux_resume_one_lwp_throw instead of linux_resume_one_lwp.
2015-03-19 16:12:33 +01:00
{
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
resume_one_lwp_throw (lwp, step, signal, info);
Fix race exposed by gdb.threads/killed.exp On GNU/Linux, this test sometimes FAILs like this: (gdb) run Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/killed [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". ptrace: No such process. (gdb) Program terminated with signal SIGKILL, Killed. The program no longer exists. FAIL: gdb.threads/killed.exp: run program to completion (timeout) Note the suspicious "No such process" line (that's errno==ESRCH). Adding debug output we see: linux_nat_wait: [process -1], [TARGET_WNOHANG] LLW: enter LNW: waitpid(-1, ...) returned 18465, ERRNO-OK LLW: waitpid 18465 received Stopped (signal) (stopped) LNW: waitpid(-1, ...) returned 18461, ERRNO-OK LLW: waitpid 18461 received Trace/breakpoint trap (stopped) LLW: Handling extended status 0x03057f LHEW: Got clone event from LWP 18461, new child is LWP 18465 LNW: waitpid(-1, ...) returned 0, ERRNO-OK RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0 RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0 sigchld ptrace: No such process. (gdb) linux_nat_wait: [process -1], [TARGET_WNOHANG] LLW: enter LNW: waitpid(-1, ...) returned 18465, ERRNO-OK LLW: waitpid 18465 received Killed (terminated) LLW: LWP 18465 exited. LNW: waitpid(-1, ...) returned 18461, No child processes LLW: waitpid 18461 received Killed (terminated) Process 18461 exited LNW: waitpid(-1, ...) returned -1, No child processes LLW: exit sigchld infrun: target_wait (-1, status) = infrun: 18461 [process 18461], infrun: status->kind = signalled, signal = GDB_SIGNAL_KILL infrun: TARGET_WAITKIND_SIGNALLED Program terminated with signal SIGKILL, Killed. The program no longer exists. infrun: stop_waiting FAIL: gdb.threads/killed.exp: run program to completion (timeout) The issue is that here: RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0 RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0 The first line shows we had just resumed LWP 18465, which does: void * child_func (void *dummy) { kill (pid, SIGKILL); exit (1); } So if the kernel manages to schedule that thread fast enough, the process may be killed before GDB has a chance to resume LWP 18461. GDBserver has code at the tail end of linux_resume_one_lwp to cope with this: ~~~ ptrace (step ? PTRACE_SINGLESTEP : PTRACE_CONT, lwpid_of (thread), (PTRACE_TYPE_ARG3) 0, /* Coerce to a uintptr_t first to avoid potential gcc warning of coercing an 8 byte integer to a 4 byte pointer. */ (PTRACE_TYPE_ARG4) (uintptr_t) signal); current_thread = saved_thread; if (errno) { /* ESRCH from ptrace either means that the thread was already running (an error) or that it is gone (a race condition). If it's gone, we will get a notification the next time we wait, so we can ignore the error. We could differentiate these two, but it's tricky without waiting; the thread still exists as a zombie, so sending it signal 0 would succeed. So just ignore ESRCH. */ if (errno == ESRCH) return; perror_with_name ("ptrace"); } ~~~ However, that's not a complete fix, because between starting to handle the resume request and getting that PTRACE_CONTINUE, we run other ptrace calls that can also fail with ESRCH, and that end up throwing an error (with perror_with_name). In the case above, I indeed sometimes see resume_stopped_resumed_lwps fail in the registers read: resume_stopped_resumed_lwps (struct lwp_info *lp, void *data) { ... CORE_ADDR pc = regcache_read_pc (regcache); Or e.g., in 32-bit mode, i386_linux_resume has several calls that can throw too. Whether to ignore ptrace errors or not depends on context that is only available somewhere up the call chain. So the fix is to let ptrace errors throw as they do today, and wrap the resume request in a TRY/CATCH that swallows it iff the lwp that we were trying to resume is no longer ptrace-stopped. gdb/gdbserver/ChangeLog: 2015-03-19 Pedro Alves <palves@redhat.com> * linux-low.c (linux_resume_one_lwp): Rename to ... (linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here, instead call perror_with_name. (check_ptrace_stopped_lwp_gone): New function. (linux_resume_one_lwp): Reimplement as wrapper around linux_resume_one_lwp_throw that swallows errors if the LWP is gone. gdb/ChangeLog: 2015-03-19 Pedro Alves <palves@redhat.com> * linux-nat.c (linux_resume_one_lwp): Rename to ... (linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here, instead call perror_with_name. (check_ptrace_stopped_lwp_gone): New function. (linux_resume_one_lwp): Reimplement as wrapper around linux_resume_one_lwp_throw that swallows errors if the LWP is gone. (resume_stopped_resumed_lwps): Try register reads in TRY/CATCH and swallows errors if the LWP is gone. Use linux_resume_one_lwp_throw instead of linux_resume_one_lwp.
2015-03-19 16:12:33 +01:00
}
Rename gdb exception types This renames the gdb exception types. The old types were only needed due to the macros in common-exception.h that are now gone. The intermediate layer of gdb_exception_RETURN_MASK_ALL did not seem needed, so this patch removes it entirely. gdb/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * common/common-exceptions.h (gdb_exception_RETURN_MASK_ALL): Remove. (gdb_exception_error): Rename from gdb_exception_RETURN_MASK_ERROR. (gdb_exception_quit): Rename from gdb_exception_RETURN_MASK_QUIT. (gdb_quit_bad_alloc): Update. * aarch64-tdep.c: Update. * ada-lang.c: Update. * ada-typeprint.c: Update. * ada-valprint.c: Update. * amd64-tdep.c: Update. * arch-utils.c: Update. * break-catch-throw.c: Update. * breakpoint.c: Update. * btrace.c: Update. * c-varobj.c: Update. * cli/cli-cmds.c: Update. * cli/cli-interp.c: Update. * cli/cli-script.c: Update. * common/common-exceptions.c: Update. * common/new-op.c: Update. * common/selftest.c: Update. * compile/compile-c-symbols.c: Update. * compile/compile-cplus-symbols.c: Update. * compile/compile-object-load.c: Update. * compile/compile-object-run.c: Update. * completer.c: Update. * corelow.c: Update. * cp-abi.c: Update. * cp-support.c: Update. * cp-valprint.c: Update. * darwin-nat.c: Update. * disasm-selftests.c: Update. * dtrace-probe.c: Update. * dwarf-index-cache.c: Update. * dwarf-index-write.c: Update. * dwarf2-frame-tailcall.c: Update. * dwarf2-frame.c: Update. * dwarf2loc.c: Update. * dwarf2read.c: Update. * eval.c: Update. * event-loop.c: Update. * event-top.c: Update. * exec.c: Update. * f-valprint.c: Update. * fbsd-tdep.c: Update. * frame-unwind.c: Update. * frame.c: Update. * gdbtypes.c: Update. * gnu-v3-abi.c: Update. * guile/guile-internal.h: Update. * guile/scm-block.c: Update. * guile/scm-breakpoint.c: Update. * guile/scm-cmd.c: Update. * guile/scm-disasm.c: Update. * guile/scm-frame.c: Update. * guile/scm-lazy-string.c: Update. * guile/scm-math.c: Update. * guile/scm-param.c: Update. * guile/scm-ports.c: Update. * guile/scm-pretty-print.c: Update. * guile/scm-symbol.c: Update. * guile/scm-symtab.c: Update. * guile/scm-type.c: Update. * guile/scm-value.c: Update. * i386-linux-tdep.c: Update. * i386-tdep.c: Update. * inf-loop.c: Update. * infcall.c: Update. * infcmd.c: Update. * infrun.c: Update. * jit.c: Update. * language.c: Update. * linespec.c: Update. * linux-fork.c: Update. * linux-nat.c: Update. * linux-tdep.c: Update. * linux-thread-db.c: Update. * main.c: Update. * mi/mi-cmd-break.c: Update. * mi/mi-cmd-stack.c: Update. * mi/mi-interp.c: Update. * mi/mi-main.c: Update. * objc-lang.c: Update. * p-valprint.c: Update. * parse.c: Update. * ppc-linux-tdep.c: Update. * printcmd.c: Update. * python/py-arch.c: Update. * python/py-breakpoint.c: Update. * python/py-cmd.c: Update. * python/py-finishbreakpoint.c: Update. * python/py-frame.c: Update. * python/py-framefilter.c: Update. * python/py-gdb-readline.c: Update. * python/py-inferior.c: Update. * python/py-infthread.c: Update. * python/py-lazy-string.c: Update. * python/py-linetable.c: Update. * python/py-objfile.c: Update. * python/py-param.c: Update. * python/py-prettyprint.c: Update. * python/py-progspace.c: Update. * python/py-record-btrace.c: Update. * python/py-record.c: Update. * python/py-symbol.c: Update. * python/py-type.c: Update. * python/py-unwind.c: Update. * python/py-utils.c: Update. * python/py-value.c: Update. * python/python.c: Update. * record-btrace.c: Update. * record-full.c: Update. * remote-fileio.c: Update. * remote.c: Update. * riscv-tdep.c: Update. * rs6000-aix-tdep.c: Update. * rs6000-tdep.c: Update. * rust-exp.y: Update. * rust-lang.c: Update. * s390-tdep.c: Update. * selftest-arch.c: Update. * solib-dsbt.c: Update. * solib-frv.c: Update. * solib-spu.c: Update. * solib-svr4.c: Update. * solib.c: Update. * sparc64-linux-tdep.c: Update. * stack.c: Update. * symfile-mem.c: Update. * symmisc.c: Update. * target.c: Update. * thread.c: Update. * top.c: Update. * tracefile-tfile.c: Update. * tui/tui.c: Update. * typeprint.c: Update. * unittests/cli-utils-selftests.c: Update. * unittests/parse-connection-spec-selftests.c: Update. * valops.c: Update. * valprint.c: Update. * value.c: Update. * varobj.c: Update. * windows-nat.c: Update. * x86-linux-nat.c: Update. * xml-support.c: Update. gdb/gdbserver/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * gdbreplay.c: Update. * linux-low.c: Update. * server.c: Update.
2019-04-03 23:59:07 +02:00
catch (const gdb_exception_error &ex)
Fix race exposed by gdb.threads/killed.exp On GNU/Linux, this test sometimes FAILs like this: (gdb) run Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/killed [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". ptrace: No such process. (gdb) Program terminated with signal SIGKILL, Killed. The program no longer exists. FAIL: gdb.threads/killed.exp: run program to completion (timeout) Note the suspicious "No such process" line (that's errno==ESRCH). Adding debug output we see: linux_nat_wait: [process -1], [TARGET_WNOHANG] LLW: enter LNW: waitpid(-1, ...) returned 18465, ERRNO-OK LLW: waitpid 18465 received Stopped (signal) (stopped) LNW: waitpid(-1, ...) returned 18461, ERRNO-OK LLW: waitpid 18461 received Trace/breakpoint trap (stopped) LLW: Handling extended status 0x03057f LHEW: Got clone event from LWP 18461, new child is LWP 18465 LNW: waitpid(-1, ...) returned 0, ERRNO-OK RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0 RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0 sigchld ptrace: No such process. (gdb) linux_nat_wait: [process -1], [TARGET_WNOHANG] LLW: enter LNW: waitpid(-1, ...) returned 18465, ERRNO-OK LLW: waitpid 18465 received Killed (terminated) LLW: LWP 18465 exited. LNW: waitpid(-1, ...) returned 18461, No child processes LLW: waitpid 18461 received Killed (terminated) Process 18461 exited LNW: waitpid(-1, ...) returned -1, No child processes LLW: exit sigchld infrun: target_wait (-1, status) = infrun: 18461 [process 18461], infrun: status->kind = signalled, signal = GDB_SIGNAL_KILL infrun: TARGET_WAITKIND_SIGNALLED Program terminated with signal SIGKILL, Killed. The program no longer exists. infrun: stop_waiting FAIL: gdb.threads/killed.exp: run program to completion (timeout) The issue is that here: RSRL: resuming stopped-resumed LWP LWP 18465 at 0x3b36af4b51: step=0 RSRL: resuming stopped-resumed LWP LWP 18461 at 0x3b36af4b51: step=0 The first line shows we had just resumed LWP 18465, which does: void * child_func (void *dummy) { kill (pid, SIGKILL); exit (1); } So if the kernel manages to schedule that thread fast enough, the process may be killed before GDB has a chance to resume LWP 18461. GDBserver has code at the tail end of linux_resume_one_lwp to cope with this: ~~~ ptrace (step ? PTRACE_SINGLESTEP : PTRACE_CONT, lwpid_of (thread), (PTRACE_TYPE_ARG3) 0, /* Coerce to a uintptr_t first to avoid potential gcc warning of coercing an 8 byte integer to a 4 byte pointer. */ (PTRACE_TYPE_ARG4) (uintptr_t) signal); current_thread = saved_thread; if (errno) { /* ESRCH from ptrace either means that the thread was already running (an error) or that it is gone (a race condition). If it's gone, we will get a notification the next time we wait, so we can ignore the error. We could differentiate these two, but it's tricky without waiting; the thread still exists as a zombie, so sending it signal 0 would succeed. So just ignore ESRCH. */ if (errno == ESRCH) return; perror_with_name ("ptrace"); } ~~~ However, that's not a complete fix, because between starting to handle the resume request and getting that PTRACE_CONTINUE, we run other ptrace calls that can also fail with ESRCH, and that end up throwing an error (with perror_with_name). In the case above, I indeed sometimes see resume_stopped_resumed_lwps fail in the registers read: resume_stopped_resumed_lwps (struct lwp_info *lp, void *data) { ... CORE_ADDR pc = regcache_read_pc (regcache); Or e.g., in 32-bit mode, i386_linux_resume has several calls that can throw too. Whether to ignore ptrace errors or not depends on context that is only available somewhere up the call chain. So the fix is to let ptrace errors throw as they do today, and wrap the resume request in a TRY/CATCH that swallows it iff the lwp that we were trying to resume is no longer ptrace-stopped. gdb/gdbserver/ChangeLog: 2015-03-19 Pedro Alves <palves@redhat.com> * linux-low.c (linux_resume_one_lwp): Rename to ... (linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here, instead call perror_with_name. (check_ptrace_stopped_lwp_gone): New function. (linux_resume_one_lwp): Reimplement as wrapper around linux_resume_one_lwp_throw that swallows errors if the LWP is gone. gdb/ChangeLog: 2015-03-19 Pedro Alves <palves@redhat.com> * linux-nat.c (linux_resume_one_lwp): Rename to ... (linux_resume_one_lwp_throw): ... this. Don't handle ESRCH here, instead call perror_with_name. (check_ptrace_stopped_lwp_gone): New function. (linux_resume_one_lwp): Reimplement as wrapper around linux_resume_one_lwp_throw that swallows errors if the LWP is gone. (resume_stopped_resumed_lwps): Try register reads in TRY/CATCH and swallows errors if the LWP is gone. Use linux_resume_one_lwp_throw instead of linux_resume_one_lwp.
2015-03-19 16:12:33 +01:00
{
if (!check_ptrace_stopped_lwp_gone (lwp))
Replace throw_exception with throw in some cases This replaces throw_exception with "throw;" when possible. This was written by script. The rule that is followed is that uses of the form: catch (... &name) { ... throw_exception (name); } ... can be rewritten. This should always be safe, because exceptions are caught by const reference, and therefore can't be modified in the body of the catch. gdb/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * valops.c (value_rtti_indirect_type): Replace throw_exception with throw. * tracefile-tfile.c (tfile_target_open): Replace throw_exception with throw. * thread.c (thr_try_catch_cmd): Replace throw_exception with throw. * target.c (target_translate_tls_address): Replace throw_exception with throw. * stack.c (frame_apply_command_count): Replace throw_exception with throw. * solib-spu.c (append_ocl_sos): Replace throw_exception with throw. * s390-tdep.c (s390_frame_unwind_cache): Replace throw_exception with throw. * rs6000-tdep.c (rs6000_frame_cache) (rs6000_epilogue_frame_cache): Replace throw_exception with throw. * remote.c: Replace throw_exception with throw. * record-full.c (record_full_message, record_full_wait_1) (record_full_restore): Replace throw_exception with throw. * record-btrace.c: (get_thread_current_frame_id, record_btrace_start_replaying) (cmd_record_btrace_bts_start, cmd_record_btrace_pt_start) (cmd_record_btrace_start): Replace throw_exception with throw. * parse.c (parse_exp_in_context_1): Replace throw_exception with throw. * linux-nat.c (detach_one_lwp, linux_resume_one_lwp) (resume_stopped_resumed_lwps): Replace throw_exception with throw. * linespec.c: (find_linespec_symbols): Replace throw_exception with throw. * infrun.c (displaced_step_prepare, resume): Replace throw_exception with throw. * infcmd.c (post_create_inferior): Replace throw_exception with throw. * inf-loop.c (inferior_event_handler): Replace throw_exception with throw. * i386-tdep.c (i386_frame_cache, i386_epilogue_frame_cache) (i386_sigtramp_frame_cache): Replace throw_exception with throw. * frame.c (frame_unwind_pc, get_prev_frame_if_no_cycle) (get_prev_frame_always, get_frame_pc_if_available) (get_frame_address_in_block_if_available, get_frame_language): Replace throw_exception with throw. * frame-unwind.c (frame_unwind_try_unwinder): Replace throw_exception with throw. * eval.c (fetch_subexp_value, evaluate_var_value) (evaluate_funcall, evaluate_subexp_standard): Replace throw_exception with throw. * dwarf2loc.c (call_site_find_chain) (dwarf2_evaluate_loc_desc_full, dwarf2_locexpr_baton_eval): Replace throw_exception with throw. * dwarf2-frame.c (dwarf2_frame_cache): Replace throw_exception with throw. * darwin-nat.c (darwin_attach_pid): Replace throw_exception with throw. * cp-abi.c (baseclass_offset): Replace throw_exception with throw. * completer.c (complete_line_internal): Replace throw_exception with throw. * compile/compile-object-run.c (compile_object_run): Replace throw_exception with throw. * cli/cli-script.c (process_next_line): Replace throw_exception with throw. * btrace.c (btrace_compute_ftrace_pt, btrace_compute_ftrace) (btrace_enable, btrace_maint_update_pt_packets): Replace throw_exception with throw. * breakpoint.c (create_breakpoint, save_breakpoints): Replace throw_exception with throw. * break-catch-throw.c (re_set_exception_catchpoint): Replace throw_exception with throw. * amd64-tdep.c (amd64_frame_cache, amd64_sigtramp_frame_cache) (amd64_epilogue_frame_cache): Replace throw_exception with throw. * aarch64-tdep.c (aarch64_make_prologue_cache) (aarch64_make_stub_cache): Replace throw_exception with throw. gdb/gdbserver/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * linux-low.c (linux_detach_one_lwp): Replace throw_exception with throw. (linux_resume_one_lwp): Likewise.
2019-01-28 18:45:45 +01:00
throw;
}
}
/* This function is called once per thread via for_each_thread.
We look up which resume request applies to THREAD and mark it with a
pointer to the appropriate resume request.
This algorithm is O(threads * resume elements), but resume elements
is small (and will remain small at least until GDB supports thread
suspension). */
static void
linux_set_resume_request (thread_info *thread, thread_resume *resume, size_t n)
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
{
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
struct lwp_info *lwp = get_thread_lwp (thread);
for (int ndx = 0; ndx < n; ndx++)
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
{
ptid_t ptid = resume[ndx].thread;
2018-06-11 22:45:22 +02:00
if (ptid == minus_one_ptid
gdbserver: use std::list for all_threads Remove the usage of inferior_list for the all_threads list in gdbserver. The entry field in thread_info is removed, and replaced by a simple ptid field. I added some functions to iterate (for_each_thread) and find threads (find_thread). However, changing all the users of find_inferior & co to use these new functions would have made the patch way too big. So I opted instead to make find_inferior & co some shims, so that the existing code only needs to be updated minimally. We can then update the existing code to use the new functions incrementally (I've started to do the work, but I'll post it afterwards, see [1] if you want a peek). This patch has been built-tested on all relevant platforms, except lynx. I also regtested using the native-gdbserver and native-extended-gdbserver boards on x86. [1] https://github.com/simark/binutils-gdb/commits/kill-inferior-list-entry gdb/gdbserver/ChangeLog: * inferiors.h: (struct inferior_list): Remove. (struct inferior_list_entry); Remove. (add_inferior_to_list, clear_inferior_list, one_inferior_p, A_I_NEXT, ALL_INFERIORS_TYPE, ALL_INFERIORS, remove_inferior, get_first_inferior): Remove. (for_each_inferior, for_each_inferior_with_data, find_inferior, find_inferior_id, find_inferior_in_random): Change signature. * inferiors.c (all_threads): Change type to std::list<thread_info *>. (get_thread): Remove macro. (find_inferior, find_inferior_id): Change signature, implement using find_thread. (find_inferior_in_random): Change signature, implement using find_thread_in_random. (for_each_inferior, for_each_inferior_with_data): Change signature, implement using for_each_thread. (add_inferior_to_list, remove_inferior): Remove. (add_thread, get_first_thread, thread_of_pid, find_any_thread_of_pid, free_one_thread, remove_thread): Update. (get_first_inferior, one_inferior_p, clear_inferior_list): Remove. (clear_inferiors, get_thread_process): Update. * gdbthread.h: Include <list>. (struct thread_info) <entry>: Remove field. <id>: New field. (all_threads): Change type to std::list<thread_info *>. (get_first_inferior): Add doc. (find_thread, for_each_thread, find_thread_in_random): New functions. (current_ptid, pid_of, ptid_of, lwpid_of): Update. * linux-arm-low.c (update_registers_callback): Update. * linux-low.c (second_thread_of_pid_p): Update. (kill_one_lwp_callback, linux_detach_lwp_callback, delete_lwp_callback, status_pending_p_callback, same_lwp, find_lwp_pid, num_lwps, iterate_over_lwps_filter, iterate_over_lwps, not_stopped_callback, resume_stopped_resumed_lwps, count_events_callback, select_singlestep_lwp_callback, select_event_lwp_callback, unsuspend_one_lwp, linux_wait_1, send_sigstop_callback, suspend_and_send_sigstop_callback, wait_for_sigstop, stuck_in_jump_pad_callback, move_out_of_jump_pad_callback, lwp_running, linux_set_resume_request, resume_status_pending_p, need_step_over_p, start_step_over, linux_resume_one_thread, proceed_one_lwp, unsuspend_and_proceed_one_lwp, reset_lwp_ptrace_options_callback): Update. * linux-mips-low.c (update_watch_registers_callback): Update. * regcache.c (regcache_invalidate_one, regcache_invalidate): Update. (free_register_cache_thread_one): Remove. (regcache_release): Update. * server.c (handle_btrace_enable_bts, handle_btrace_enable_pt, handle_qxfer_threads_worker): Update. (handle_query): Update, use list iterator. (visit_actioned_threads, handle_pending_status, queue_stop_reply_callback, gdb_wants_all_threads_stopped, clear_pending_status_callback, set_pending_status_callback, find_status_pending_thread_callback, handle_status, process_serial_event): Update. * target.c (thread_search_callback): Update. * thread-db.c (thread_db_get_tls_address): Update. * tracepoint.c (tracepoint_finished_step, tracepoint_was_hit): Update. * win32-i386-low.c (update_debug_registers_callback): Update. * win32-low.c (delete_thread_info, child_delete_thread, continue_one_thread, suspend_one_thread, get_child_debug_event): Adjust.
2017-10-14 15:11:12 +02:00
|| ptid == thread->id
/* Handle both 'pPID' and 'pPID.-1' as meaning 'all threads
of PID'. */
Remove ptid_get_pid This removes ptid_get_pid in favor of calling the ptid_t::pid method. gdb/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * common/ptid.c (ptid_get_pid): Remove. * common/ptid.h (ptid_get_pid): Don't declare. * aarch64-linux-nat.c: Update. * ada-lang.c: Update. * aix-thread.c: Update. * alpha-bsd-nat.c: Update. * amd64-fbsd-nat.c: Update. * amd64-linux-nat.c: Update. * arm-linux-nat.c: Update. * arm-nbsd-nat.c: Update. * auxv.c: Update. * break-catch-syscall.c: Update. * breakpoint.c: Update. * bsd-uthread.c: Update. * corelow.c: Update. * ctf.c: Update. * darwin-nat.c: Update. * fbsd-nat.c: Update. * fbsd-tdep.c: Update. * gcore.c: Update. * gnu-nat.c: Update. * hppa-nbsd-nat.c: Update. * hppa-obsd-nat.c: Update. * i386-fbsd-nat.c: Update. * ia64-linux-nat.c: Update. * inf-ptrace.c: Update. * infcmd.c: Update. * inferior.c: Update. * inferior.h: Update. * inflow.c: Update. * infrun.c: Update. * linux-fork.c: Update. * linux-nat.c: Update. * linux-tdep.c: Update. * linux-thread-db.c: Update. * m68k-bsd-nat.c: Update. * mi/mi-interp.c: Update. * mi/mi-main.c: Update. * mips-linux-nat.c: Update. * mips-nbsd-nat.c: Update. * mips64-obsd-nat.c: Update. * nat/aarch64-linux-hw-point.c: Update. * nat/aarch64-linux.c: Update. * nat/linux-btrace.c: Update. * nat/linux-osdata.c: Update. * nat/linux-procfs.c: Update. * nat/x86-linux-dregs.c: Update. * nto-procfs.c: Update. * obsd-nat.c: Update. * ppc-linux-nat.c: Update. * ppc-nbsd-nat.c: Update. * ppc-obsd-nat.c: Update. * proc-service.c: Update. * procfs.c: Update. * python/py-inferior.c: Update. * python/py-infthread.c: Update. * ravenscar-thread.c: Update. * record.c: Update. * remote-sim.c: Update. * remote.c: Update. * rs6000-nat.c: Update. * s390-linux-nat.c: Update. * sh-nbsd-nat.c: Update. * sol-thread.c: Update. * sparc-nat.c: Update. * sparc64-tdep.c: Update. * spu-linux-nat.c: Update. * spu-tdep.c: Update. * target-debug.h: Update. * target.c: Update. * thread.c: Update. * tid-parse.c: Update. * tracefile-tfile.c: Update. * vax-bsd-nat.c: Update. * windows-nat.c: Update. * x86-linux-nat.c: Update. * x86-nat.c: Update. gdb/gdbserver/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * linux-low.c: Update. * linux-mips-low.c: Update. * lynx-low.c: Update. * mem-break.c: Update. * nto-low.c: Update. * remote-utils.c: Update. * server.c: Update. * spu-low.c: Update. * target.c: Update. * tracepoint.c: Update.
2018-06-11 20:05:27 +02:00
|| (ptid.pid () == pid_of (thread)
&& (ptid.is_pid ()
Remove ptid_get_lwp This removes ptid_get_lwp in favor of calling the ptid_t::lwp method. gdb/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * common/ptid.c (ptid_get_lwp): Remove. * common/ptid.h (ptid_get_lwp): Don't declare. * aarch64-linux-nat.c: Update. * ada-tasks.c: Update. * aix-thread.c: Update. * amd64-linux-nat.c: Update. * arm-linux-nat.c: Update. * corelow.c: Update. * fbsd-nat.c: Update. * fbsd-tdep.c: Update. * gnu-nat.c: Update. * i386-cygwin-tdep.c: Update. * i386-gnu-nat.c: Update. * i386-linux-nat.c: Update. * ia64-linux-nat.c: Update. * inf-ptrace.c: Update. * infrun.c: Update. * linux-fork.c: Update. * linux-nat.c: Update. * linux-tdep.c: Update. * linux-thread-db.c: Update. * mips-linux-nat.c: Update. * nat/aarch64-linux-hw-point.c: Update. * nat/aarch64-linux.c: Update. * nat/linux-btrace.c: Update. * nat/linux-osdata.c: Update. * nat/linux-procfs.c: Update. * nat/x86-linux-dregs.c: Update. * obsd-nat.c: Update. * ppc-fbsd-nat.c: Update. * ppc-linux-nat.c: Update. * procfs.c: Update. * python/py-infthread.c: Update. * ravenscar-thread.c: Update. * remote.c: Update. * s390-linux-nat.c: Update. * sol-thread.c: Update. * sol2-tdep.c: Update. * spu-linux-nat.c: Update. * x86-linux-nat.c: Update. * xtensa-linux-nat.c: Update. gdb/gdbserver/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * linux-low.c: Update. * linux-mips-low.c: Update. * lynx-low.c: Update. * nto-low.c: Update. * remote-utils.c: Update. * server.c: Update. * spu-low.c: Update. * target.c: Update. * thread-db.c: Update.
2018-06-11 20:10:09 +02:00
|| ptid.lwp () == -1)))
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
{
if (resume[ndx].kind == resume_stop
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
&& thread->last_resume_kind == resume_stop)
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("already %s LWP %ld at GDB's request\n",
(thread->last_status.kind
== TARGET_WAITKIND_STOPPED)
? "stopped"
: "stopping",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
lwpid_of (thread));
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
continue;
}
gdbserver: Leave already-vCont-resumed threads as they were Currently GDB never sends more than one action per vCont packet, when connected in non-stop mode. A follow up patch will change that, and it exposed a gdbserver problem with the vCont handling. For example, this in non-stop mode: => vCont;s:p1.1;c <= OK Should be equivalent to: => vCont;s:p1.1 <= OK => vCont;c <= OK But gdbserver currently doesn't handle this. In the latter case, "vCont;c" makes gdbserver clobber the previous step request. This patch fixes that. Note the server side must ignore resume actions for the thread that has a pending %Stopped notification (and any other threads with events pending), until GDB acks the notification with vStopped. Otherwise, e.g., the following case is mishandled: #1 => g (or any other packet) #2 <= [registers] #3 <= %Stopped T05 thread:p1.2 #4 => vCont s:p1.1;c #5 <= OK Above, the server must not resume thread p1.2 when it processes the vCont. GDB can't know that p1.2 stopped until it acks the %Stopped notification. (Otherwise it wouldn't send a default "c" action.) (The vCont documentation already specifies this.) Finally, special care must also be given to handling fork/vfork events. A (v)fork event actually tells us that two processes stopped -- the parent and the child. Until we follow the fork, we must not resume the child. Therefore, if we have a pending fork follow, we must not send a global wildcard resume action (vCont;c). We can still send process-wide wildcards though. (The comments above will be added as code comments to gdb in a follow up patch.) gdb/gdbserver/ChangeLog: 2016-10-26 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Link parent/child fork threads. (linux_wait_1): Unlink them. (linux_set_resume_request): Ignore resume requests for already-resumed and unhandled fork child threads. * linux-low.h (struct lwp_info) <fork_relative>: New field. * server.c (in_queued_stop_replies_ptid, in_queued_stop_replies): New functions. (handle_v_requests) <vCont>: Don't call require_running. * server.h (in_queued_stop_replies): New declaration.
2016-10-26 17:17:25 +02:00
/* Ignore (wildcard) resume requests for already-resumed
threads. */
if (resume[ndx].kind != resume_stop
gdbserver: Leave already-vCont-resumed threads as they were Currently GDB never sends more than one action per vCont packet, when connected in non-stop mode. A follow up patch will change that, and it exposed a gdbserver problem with the vCont handling. For example, this in non-stop mode: => vCont;s:p1.1;c <= OK Should be equivalent to: => vCont;s:p1.1 <= OK => vCont;c <= OK But gdbserver currently doesn't handle this. In the latter case, "vCont;c" makes gdbserver clobber the previous step request. This patch fixes that. Note the server side must ignore resume actions for the thread that has a pending %Stopped notification (and any other threads with events pending), until GDB acks the notification with vStopped. Otherwise, e.g., the following case is mishandled: #1 => g (or any other packet) #2 <= [registers] #3 <= %Stopped T05 thread:p1.2 #4 => vCont s:p1.1;c #5 <= OK Above, the server must not resume thread p1.2 when it processes the vCont. GDB can't know that p1.2 stopped until it acks the %Stopped notification. (Otherwise it wouldn't send a default "c" action.) (The vCont documentation already specifies this.) Finally, special care must also be given to handling fork/vfork events. A (v)fork event actually tells us that two processes stopped -- the parent and the child. Until we follow the fork, we must not resume the child. Therefore, if we have a pending fork follow, we must not send a global wildcard resume action (vCont;c). We can still send process-wide wildcards though. (The comments above will be added as code comments to gdb in a follow up patch.) gdb/gdbserver/ChangeLog: 2016-10-26 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Link parent/child fork threads. (linux_wait_1): Unlink them. (linux_set_resume_request): Ignore resume requests for already-resumed and unhandled fork child threads. * linux-low.h (struct lwp_info) <fork_relative>: New field. * server.c (in_queued_stop_replies_ptid, in_queued_stop_replies): New functions. (handle_v_requests) <vCont>: Don't call require_running. * server.h (in_queued_stop_replies): New declaration.
2016-10-26 17:17:25 +02:00
&& thread->last_resume_kind != resume_stop)
{
if (debug_threads)
debug_printf ("already %s LWP %ld at GDB's request\n",
(thread->last_resume_kind
== resume_step)
? "stepping"
: "continuing",
lwpid_of (thread));
continue;
}
/* Don't let wildcard resumes resume fork children that GDB
does not yet know are new fork children. */
if (lwp->fork_relative != NULL)
{
struct lwp_info *rel = lwp->fork_relative;
if (rel->status_pending_p
&& (rel->waitstatus.kind == TARGET_WAITKIND_FORKED
|| rel->waitstatus.kind == TARGET_WAITKIND_VFORKED))
{
if (debug_threads)
debug_printf ("not resuming LWP %ld: has queued stop reply\n",
lwpid_of (thread));
continue;
}
}
/* If the thread has a pending event that has already been
reported to GDBserver core, but GDB has not pulled the
event out of the vStopped queue yet, likewise, ignore the
(wildcard) resume request. */
gdbserver: use std::list for all_threads Remove the usage of inferior_list for the all_threads list in gdbserver. The entry field in thread_info is removed, and replaced by a simple ptid field. I added some functions to iterate (for_each_thread) and find threads (find_thread). However, changing all the users of find_inferior & co to use these new functions would have made the patch way too big. So I opted instead to make find_inferior & co some shims, so that the existing code only needs to be updated minimally. We can then update the existing code to use the new functions incrementally (I've started to do the work, but I'll post it afterwards, see [1] if you want a peek). This patch has been built-tested on all relevant platforms, except lynx. I also regtested using the native-gdbserver and native-extended-gdbserver boards on x86. [1] https://github.com/simark/binutils-gdb/commits/kill-inferior-list-entry gdb/gdbserver/ChangeLog: * inferiors.h: (struct inferior_list): Remove. (struct inferior_list_entry); Remove. (add_inferior_to_list, clear_inferior_list, one_inferior_p, A_I_NEXT, ALL_INFERIORS_TYPE, ALL_INFERIORS, remove_inferior, get_first_inferior): Remove. (for_each_inferior, for_each_inferior_with_data, find_inferior, find_inferior_id, find_inferior_in_random): Change signature. * inferiors.c (all_threads): Change type to std::list<thread_info *>. (get_thread): Remove macro. (find_inferior, find_inferior_id): Change signature, implement using find_thread. (find_inferior_in_random): Change signature, implement using find_thread_in_random. (for_each_inferior, for_each_inferior_with_data): Change signature, implement using for_each_thread. (add_inferior_to_list, remove_inferior): Remove. (add_thread, get_first_thread, thread_of_pid, find_any_thread_of_pid, free_one_thread, remove_thread): Update. (get_first_inferior, one_inferior_p, clear_inferior_list): Remove. (clear_inferiors, get_thread_process): Update. * gdbthread.h: Include <list>. (struct thread_info) <entry>: Remove field. <id>: New field. (all_threads): Change type to std::list<thread_info *>. (get_first_inferior): Add doc. (find_thread, for_each_thread, find_thread_in_random): New functions. (current_ptid, pid_of, ptid_of, lwpid_of): Update. * linux-arm-low.c (update_registers_callback): Update. * linux-low.c (second_thread_of_pid_p): Update. (kill_one_lwp_callback, linux_detach_lwp_callback, delete_lwp_callback, status_pending_p_callback, same_lwp, find_lwp_pid, num_lwps, iterate_over_lwps_filter, iterate_over_lwps, not_stopped_callback, resume_stopped_resumed_lwps, count_events_callback, select_singlestep_lwp_callback, select_event_lwp_callback, unsuspend_one_lwp, linux_wait_1, send_sigstop_callback, suspend_and_send_sigstop_callback, wait_for_sigstop, stuck_in_jump_pad_callback, move_out_of_jump_pad_callback, lwp_running, linux_set_resume_request, resume_status_pending_p, need_step_over_p, start_step_over, linux_resume_one_thread, proceed_one_lwp, unsuspend_and_proceed_one_lwp, reset_lwp_ptrace_options_callback): Update. * linux-mips-low.c (update_watch_registers_callback): Update. * regcache.c (regcache_invalidate_one, regcache_invalidate): Update. (free_register_cache_thread_one): Remove. (regcache_release): Update. * server.c (handle_btrace_enable_bts, handle_btrace_enable_pt, handle_qxfer_threads_worker): Update. (handle_query): Update, use list iterator. (visit_actioned_threads, handle_pending_status, queue_stop_reply_callback, gdb_wants_all_threads_stopped, clear_pending_status_callback, set_pending_status_callback, find_status_pending_thread_callback, handle_status, process_serial_event): Update. * target.c (thread_search_callback): Update. * thread-db.c (thread_db_get_tls_address): Update. * tracepoint.c (tracepoint_finished_step, tracepoint_was_hit): Update. * win32-i386-low.c (update_debug_registers_callback): Update. * win32-low.c (delete_thread_info, child_delete_thread, continue_one_thread, suspend_one_thread, get_child_debug_event): Adjust.
2017-10-14 15:11:12 +02:00
if (in_queued_stop_replies (thread->id))
gdbserver: Leave already-vCont-resumed threads as they were Currently GDB never sends more than one action per vCont packet, when connected in non-stop mode. A follow up patch will change that, and it exposed a gdbserver problem with the vCont handling. For example, this in non-stop mode: => vCont;s:p1.1;c <= OK Should be equivalent to: => vCont;s:p1.1 <= OK => vCont;c <= OK But gdbserver currently doesn't handle this. In the latter case, "vCont;c" makes gdbserver clobber the previous step request. This patch fixes that. Note the server side must ignore resume actions for the thread that has a pending %Stopped notification (and any other threads with events pending), until GDB acks the notification with vStopped. Otherwise, e.g., the following case is mishandled: #1 => g (or any other packet) #2 <= [registers] #3 <= %Stopped T05 thread:p1.2 #4 => vCont s:p1.1;c #5 <= OK Above, the server must not resume thread p1.2 when it processes the vCont. GDB can't know that p1.2 stopped until it acks the %Stopped notification. (Otherwise it wouldn't send a default "c" action.) (The vCont documentation already specifies this.) Finally, special care must also be given to handling fork/vfork events. A (v)fork event actually tells us that two processes stopped -- the parent and the child. Until we follow the fork, we must not resume the child. Therefore, if we have a pending fork follow, we must not send a global wildcard resume action (vCont;c). We can still send process-wide wildcards though. (The comments above will be added as code comments to gdb in a follow up patch.) gdb/gdbserver/ChangeLog: 2016-10-26 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Link parent/child fork threads. (linux_wait_1): Unlink them. (linux_set_resume_request): Ignore resume requests for already-resumed and unhandled fork child threads. * linux-low.h (struct lwp_info) <fork_relative>: New field. * server.c (in_queued_stop_replies_ptid, in_queued_stop_replies): New functions. (handle_v_requests) <vCont>: Don't call require_running. * server.h (in_queued_stop_replies): New declaration.
2016-10-26 17:17:25 +02:00
{
if (debug_threads)
debug_printf ("not resuming LWP %ld: has queued stop reply\n",
lwpid_of (thread));
continue;
}
lwp->resume = &resume[ndx];
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
thread->last_resume_kind = lwp->resume->kind;
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
range stepping: gdbserver (x86 GNU/Linux) This patch adds support for range stepping to GDBserver, teaching it about vCont;r. It'd be easy to enable this for all hardware single-step targets without needing the linux_target_ops hook, however, at least PPC needs special care, due to the fact that PPC atomic sequences can't be hardware single-stepped through, a thing which GDBserver doesn't know about. So this leaves the support limited to x86/x86_64. gdb/ 2013-05-23 Pedro Alves <palves@redhat.com> * NEWS: Mention GDBserver range stepping support. gdb/gdbserver/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * linux-low.c (lwp_in_step_range): New function. (linux_wait_1): If the thread was range stepping and stopped outside the stepping range, report the stop to GDB. Otherwise, continue stepping. Add range stepping debug output. (linux_set_resume_request): Copy the step range from the resume request to the lwp. (linux_supports_range_stepping): New. (linux_target_ops) <supports_range_stepping>: Set to linux_supports_range_stepping. * linux-low.h (struct linux_target_ops) <supports_range_stepping>: New field. (struct lwp_info) <step_range_start, step_range_end>: New fields. * linux-x86-low.c (x86_supports_range_stepping): New. (the_low_target) <supports_range_stepping>: Set to x86_supports_range_stepping. * server.c (handle_v_cont): Handle 'r' action. (handle_v_requests): Append ";r" if the target supports range stepping. * target.h (struct thread_resume) <step_range_start, step_range_end>: New fields. (struct target_ops) <supports_range_stepping>: New field. (target_supports_range_stepping): New macro.
2013-05-23 19:17:50 +02:00
lwp->step_range_start = lwp->resume->step_range_start;
lwp->step_range_end = lwp->resume->step_range_end;
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
/* If we had a deferred signal to report, dequeue one now.
This can happen if LWP gets more than one signal while
trying to get out of a jump pad. */
if (lwp->stopped
&& !lwp->status_pending_p
&& dequeue_one_deferred_signal (lwp, &lwp->status_pending))
{
lwp->status_pending_p = 1;
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Dequeueing deferred signal %d for LWP %ld, "
"leaving status pending.\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
WSTOPSIG (lwp->status_pending),
lwpid_of (thread));
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
}
return;
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
}
}
/* No resume action for this thread. */
lwp->resume = NULL;
}
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
bool
linux_process_target::resume_status_pending (thread_info *thread)
{
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
struct lwp_info *lwp = get_thread_lwp (thread);
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
/* LWPs which will not be resumed are not interesting, because
we might not wait for them next time through linux_wait. */
if (lwp->resume == NULL)
return false;
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
return thread_still_has_status_pending (thread);
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
}
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
bool
linux_process_target::thread_needs_step_over (thread_info *thread)
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
{
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
struct lwp_info *lwp = get_thread_lwp (thread);
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
struct thread_info *saved_thread;
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
CORE_ADDR pc;
Initialise target descrption after skipping extra traps for --wrapper Nowadays, when --wrapper is used, GDBserver skips extra traps/stops in the wrapper program, and stops at the first instruction of the program to be debugged. However, GDBserver created target description in the first stop of inferior, and the executable of the inferior is the wrapper program rather than the program to be debugged. In this way, the target description can be wrong if the architectures of wrapper program and program to be debugged are different. This is shown by some fails in gdb.server/wrapper.exp on buildbot. We are testing i686-linux GDB (Fedora-i686) on an x86_64-linux box (fedora-x86-64-4) in buildbot, such configuration causes fails in gdb.server/wrapper.exp like this: spawn /home/gdb-buildbot-2/fedora-x86-64-4/fedora-i686/build/gdb/testsuite/../../gdb/gdbserver/gdbserver --once --wrapper env TEST=1 -- :2346 /home/gdb-buildbot-2/fedora-x86-64-4/fedora-i686/build/gdb/testsuite/outputs/gdb.server/wrapper/wrapper Process /home/gdb-buildbot-2/fedora-x86-64-4/fedora-i686/build/gdb/testsuite/outputs/gdb.server/wrapper/wrapper created; pid = 8795 Can't debug 64-bit process with 32-bit GDBserver Exiting target remote localhost:2346 localhost:2346: Connection timed out. (gdb) FAIL: gdb.server/wrapper.exp: setting breakpoint at marker See https://sourceware.org/ml/gdb-testers/2015-q3/msg01541.html In this case, program to be debugged ("wrapper") is 32-bit but wrapper program ("/usr/bin/env") is 64-bit, so GDBserver gets the 64-bit target description instead of 32-bit. The root cause of this problem is that GDBserver creates target description too early, and the rationale of fix could be creating target description once the GDBserver skips extra traps and inferior stops at the first instruction of the program we want to debug. IOW, when GDBserver skips extra traps, the inferior's tdesc is NULL, and mywait and its callees shouldn't use inferior's tdesc, so in this patch, we skip code that requires register access, see changes in linux_resume_one_lwp_throw and need_step_over_p. In linux_low_filter_event, if target description isn't initialised and GDBserver attached the process, we create target description immediately, because GDBserver don't have to skip extra traps for attach, IOW, it makes no sense to use --attach and --wrapper together. Otherwise, the process is launched by GDBserver, we keep the status pending, and return. After GDBserver skipped extra traps in start_inferior, we call a target_ops hook arch_setup to initialise target description there. gdb/gdbserver: 2015-07-24 Yao Qi <yao.qi@linaro.org> * linux-low.c (linux_arch_setup): New function. (linux_low_filter_event): If proc->tdesc is NULL and proc->attached is true, call the_low_target.arch_setup. Otherwise, keep status pending, and return. (linux_resume_one_lwp_throw): Don't call get_pc if thread->while_stepping isn't NULL. Don't call get_thread_regcache if proc->tdesc is NULL. (need_step_over_p): Return 0 if proc->tdesc is NULL. (linux_target_ops): Install arch_setup. * server.c (start_inferior): Call the_target->arch_setup. * target.h (struct target_ops) <arch_setup>: New field. (target_arch_setup): New marco. * lynx-low.c (lynx_target_ops): Update. * nto-low.c (nto_target_ops): Update. * spu-low.c (spu_target_ops): Update. * win32-low.c (win32_target_ops): Update.
2015-07-24 15:40:34 +02:00
struct process_info *proc = get_thread_process (thread);
/* GDBserver is skipping the extra traps from the wrapper program,
don't have to do step over. */
if (proc->tdesc == NULL)
return false;
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
/* LWPs which will not be resumed are not interesting, because we
might not wait for them next time through linux_wait. */
if (!lwp->stopped)
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Need step over [LWP %ld]? Ignoring, not stopped\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
lwpid_of (thread));
return false;
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
}
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
if (thread->last_resume_kind == resume_stop)
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Need step over [LWP %ld]? Ignoring, should remain"
" stopped\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
lwpid_of (thread));
return false;
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
}
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
gdb_assert (lwp->suspended >= 0);
if (lwp->suspended)
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Need step over [LWP %ld]? Ignoring, suspended\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
lwpid_of (thread));
return false;
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
}
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
if (lwp->status_pending_p)
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Need step over [LWP %ld]? Ignoring, has pending"
" status.\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
lwpid_of (thread));
return false;
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
}
/* Note: PC, not STOP_PC. Either GDB has adjusted the PC already,
or we have. */
pc = get_pc (lwp);
/* If the PC has changed since we stopped, then don't do anything,
and let the breakpoint/tracepoint be hit. This happens if, for
instance, GDB handled the decr_pc_after_break subtraction itself,
GDB is OOL stepping this thread, or the user has issued a "jump"
command, or poked thread's registers herself. */
if (pc != lwp->stop_pc)
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Need step over [LWP %ld]? Cancelling, PC was changed. "
"Old stop_pc was 0x%s, PC is now 0x%s\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
lwpid_of (thread),
paddress (lwp->stop_pc), paddress (pc));
return false;
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
}
/* On software single step target, resume the inferior with signal
rather than stepping over. */
gdbserver/linux-low: turn 'supports_software_single_step' and 'get_next_pcs' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Remove the 'supports_software_single_step' linux target op and let the concrete linux target define it by overriding the op in process_stratum_target. Turn the 'get_next_pcs' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <supports_software_single_step>: Remove. <low_get_next_pcs>: Declare. * linux-low.cc (can_software_single_step): Remove. (linux_process_target::low_get_next_pcs): Define. (linux_process_target::supports_software_single_step): Remove. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::wait_1) (linux_process_target::install_software_single_step_breakpoints) (linux_process_target::single_step) (linux_process_target::thread_needs_step_over) (linux_process_target::proceed_one_lwp) (linux_process_target::supports_range_stepping) * linux-x86-low.cc (the_low_target): Remove the op field. * linux-aarch64-low.cc (the_low_target): Ditto. * linux-bfin-low.cc (the_low_target): Ditto. * linux-cris-low.cc (the_low_target): Ditto. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-mips-low.cc (the_low_target): Ditto. * linux-nios2-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-riscv-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-sparc-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto. * linux-arm-low.cc (class arm_target) <low_get_next_pcs> <supports_software_single_step>: Declare. (arm_target::supports_software_single_step): Define. (arm_gdbserver_get_next_pcs): Turn into... (arm_target::low_get_next_pcs): ...this. (the_low_target): Remove the op field.
2020-04-02 15:11:26 +02:00
if (supports_software_single_step ()
gdbserver/linux-low: use std::list to store pending signals Use std::list to store pending signals instead of a manually-managed linked list. This is a refactoring. In the existing code, pending signals are kept in a manually-created linked list with "prev" pointers. A new pending signal is thus inserted to the beginning of the list. When consuming, GDB goes until the end of the list, following the "prev" pointers, and processes the final item. With this patch, a new item is added to the end of the list and the item at the front of the list is consumed. In other words, the list elements used to be stored in reverse order; with this patch, they are stored in their order of arrival. This causes a change in the debug messages that print the pending signals. Otherwise, no behavioral change is expected. gdbserver/ChangeLog: 2020-06-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Use std::list to stop pending signal instead of manually-created linked list. * linux-low.h: Include <list>. (struct pending_signal): Move here from linux-low.cc. (struct lwp_info) <pending_signals> <pending_signals_to_report>: Update the type. * linux-low.cc (struct pending_signals): Remove. (linux_process_target::delete_lwp) (linux_process_target::add_lwp) (enqueue_one_deferred_signal) (dequeue_one_deferred_signal) (enqueue_pending_signal) (linux_process_target::resume_one_lwp_throw) (linux_process_target::thread_needs_step_over) (linux_process_target::resume_one_thread) (linux_process_target::proceed_one_lwp): Update the use of pending signal list.
2020-06-22 14:13:48 +02:00
&& !lwp->pending_signals.empty ()
&& lwp_signal_can_be_delivered (lwp))
{
if (debug_threads)
debug_printf ("Need step over [LWP %ld]? Ignoring, has pending"
" signals.\n",
lwpid_of (thread));
return false;
}
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
saved_thread = current_thread;
current_thread = thread;
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
* linux-low.c (linux_wait_1): Avoid setting need_step_over is there's a GDB breakpoint at stop_pc. Always report a trap to GDB if we could tell there's a GDB breakpoint at stop_pc. (need_step_over_p): Don't do a step over if we find a GDB breakpoint at the resume PC. * mem-break.c (struct raw_breakpoint): New. (enum bkpt_type): New type `gdb_breakpoint'. (struct breakpoint): Delete the `PC', `old_data' and `inserted' fields. New field `raw'. (find_raw_breakpoint_at): New. (set_raw_breakpoint_at): Handle refcounting. Create a raw breakpoint instead. (set_breakpoint_at): Adjust. (delete_raw_breakpoint): New. (release_breakpoint): New. (delete_breakpoint): Rename to... (delete_breakpoint_1): ... this. Add proc parameter. Use release_breakpoint. Return ENOENT. (delete_breakpoint): Reimplement. (find_breakpoint_at): Delete. (find_gdb_breakpoint_at): New. (delete_breakpoint_at): Delete. (set_gdb_breakpoint_at): New. (delete_gdb_breakpoint_at): New. (gdb_breakpoint_here): New. (set_reinsert_breakpoint): Use release_breakpoint. (uninsert_breakpoint): Rename to ... (uninsert_raw_breakpoint): ... this. (uninsert_breakpoints_at): Adjust to handle raw breakpoints. (reinsert_raw_breakpoint): Change parameter type to raw_breakpoint. (reinsert_breakpoints_at): Adjust to handle raw breakpoints instead. (check_breakpoints): Adjust. Use release_breakpoint. (breakpoint_here): Rewrite using find_raw_breakpoint_at. (breakpoint_inserted_here): Ditto. (check_mem_read): Adjust to iterate over raw breakpoints instead. Don't trust the breakpoint's shadow if it is not inserted. (check_mem_write): Adjust to iterate over raw breakpoints instead. (delete_all_breakpoints): Adjust. (free_all_breakpoints): Mark all breakpoints as uninserted, and use delete_breakpoint_1. * mem-break.h (breakpoints_supported): Delete declaration. (set_gdb_breakpoint_at): Declare. (gdb_breakpoint_here): Declare. (delete_breakpoint_at): Delete. (delete_gdb_breakpoint_at): Declare. * server.h (struct raw_breakpoint): Forward declare. (struct process_info): New field `raw_breakpoints'. * linux-x86-low.c (x86_insert_point, x86_remote_point): Handle Z0 breakpoints.
2010-04-01 16:25:34 +02:00
/* We can only step over breakpoints we know about. */
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
if (breakpoint_here (pc) || fast_tracepoint_jump_here (pc))
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
{
* linux-low.c (linux_wait_1): Avoid setting need_step_over is there's a GDB breakpoint at stop_pc. Always report a trap to GDB if we could tell there's a GDB breakpoint at stop_pc. (need_step_over_p): Don't do a step over if we find a GDB breakpoint at the resume PC. * mem-break.c (struct raw_breakpoint): New. (enum bkpt_type): New type `gdb_breakpoint'. (struct breakpoint): Delete the `PC', `old_data' and `inserted' fields. New field `raw'. (find_raw_breakpoint_at): New. (set_raw_breakpoint_at): Handle refcounting. Create a raw breakpoint instead. (set_breakpoint_at): Adjust. (delete_raw_breakpoint): New. (release_breakpoint): New. (delete_breakpoint): Rename to... (delete_breakpoint_1): ... this. Add proc parameter. Use release_breakpoint. Return ENOENT. (delete_breakpoint): Reimplement. (find_breakpoint_at): Delete. (find_gdb_breakpoint_at): New. (delete_breakpoint_at): Delete. (set_gdb_breakpoint_at): New. (delete_gdb_breakpoint_at): New. (gdb_breakpoint_here): New. (set_reinsert_breakpoint): Use release_breakpoint. (uninsert_breakpoint): Rename to ... (uninsert_raw_breakpoint): ... this. (uninsert_breakpoints_at): Adjust to handle raw breakpoints. (reinsert_raw_breakpoint): Change parameter type to raw_breakpoint. (reinsert_breakpoints_at): Adjust to handle raw breakpoints instead. (check_breakpoints): Adjust. Use release_breakpoint. (breakpoint_here): Rewrite using find_raw_breakpoint_at. (breakpoint_inserted_here): Ditto. (check_mem_read): Adjust to iterate over raw breakpoints instead. Don't trust the breakpoint's shadow if it is not inserted. (check_mem_write): Adjust to iterate over raw breakpoints instead. (delete_all_breakpoints): Adjust. (free_all_breakpoints): Mark all breakpoints as uninserted, and use delete_breakpoint_1. * mem-break.h (breakpoints_supported): Delete declaration. (set_gdb_breakpoint_at): Declare. (gdb_breakpoint_here): Declare. (delete_breakpoint_at): Delete. (delete_gdb_breakpoint_at): Declare. * server.h (struct raw_breakpoint): Forward declare. (struct process_info): New field `raw_breakpoints'. * linux-x86-low.c (x86_insert_point, x86_remote_point): Handle Z0 breakpoints.
2010-04-01 16:25:34 +02:00
/* Don't step over a breakpoint that GDB expects to hit
though. If the condition is being evaluated on the target's side
and it evaluate to false, step over this breakpoint as well. */
if (gdb_breakpoint_here (pc)
Add target-side support for dynamic printf. * NEWS: Mention the additional style. * breakpoint.h (struct bp_target_info): New fields tcommands, persist. (struct bp_location): New field cmd_bytecode. * breakpoint.c: Include format.h. (disconnected_dprintf): New global. (parse_cmd_to_aexpr): New function. (build_target_command_list): New function. (insert_bp_location): Call it. (remove_breakpoints_pid): Skip dprintf breakpoints. (print_one_breakpoint_location): Ditto. (dprintf_style_agent): New global. (dprintf_style_enums): Add dprintf_style_agent. (update_dprintf_command_list): Add agent case. (agent_printf_command): New function. (_initialize_breakpoint): Add new commands. * common/ax.def (printf): New bytecode. * ax.h (ax_string): Declare. * ax-gdb.h (gen_printf): Declare. * ax-gdb.c: Include cli-utils.h, format.h. (gen_printf): New function. (maint_agent_print_command): New function. (_initialize_ax_gdb): Add maint agent-printf command. * ax-general.c (ax_string): New function. (ax_print): Add printf disassembly. * Makefile.in (SFILES): Add format.c (COMMON_OBS): Add format.o. * common/format.h: New file. * common/format.c: New file. * printcmd.c: Include format.h. (ui_printf): Call parse_format_string. * remote.c (remote_state): New field breakpoint_commands. (PACKET_BreakpointCommands): New enum. (remote_breakpoint_commands_feature): New function. (remote_protocol_features): Add new BreakpointCommands entry. (remote_can_run_breakpoint_commands): New function. (remote_add_target_side_commands): New function. (remote_insert_breakpoint): Call it. (remote_insert_hw_breakpoint): Ditto. (_initialize_remote): Add new packet configuration for target-side breakpoint commands. * target.h (struct target_ops): New field to_can_run_breakpoint_commands. (target_can_run_breakpoint_commands): New macro. * target.c (update_current_target): Handle to_can_run_breakpoint_commands. [gdbserver] * Makefile.in (WARN_CFLAGS_NO_FORMAT): Define. (ax.o): Add it to build rule. (ax-ipa.o): Ditto. (OBS): Add format.o. (IPA_OBS): Add format.o. * server.c (handle_query): Claim support for breakpoint commands. (process_point_options): Add command case. (process_serial_event): Leave running if there are printfs in effect. * mem-break.h (any_persistent_commands): Declare. (add_breakpoint_commands): Declare. (gdb_no_commands_at_breakpoint): Declare. (run_breakpoint_commands): Declare. * mem-break.c (struct point_command_list): New struct. (struct breakpoint): New field command_list. (any_persistent_commands): New function. (add_commands_to_breakpoint): New function. (add_breakpoint_commands): New function. (gdb_no_commands_at_breakpoint): New function. (run_breakpoint_commands): New function. * linux-low.c (linux_wait_1): Test for and run breakpoint commands locally. * ax.c: Include format.h. (ax_printf): New function. (gdb_eval_agent_expr): Add printf opcode. [doc] * gdb.texinfo (Dynamic Printf): Mention agent style and disconnected dprintf. (Maintenance Commands): Describe maint agent-printf. (General Query Packets): Mention BreakpointCommands feature. (Packets): Document commands extension to Z0 packet. * agentexpr.texi (Bytecode Descriptions): Document printf bytecode. [testsuite] * gdb.base/dprintf.exp: Add agent style tests.
2012-07-02 17:29:39 +02:00
&& gdb_condition_true_at_breakpoint (pc)
&& gdb_no_commands_at_breakpoint (pc))
* linux-low.c (linux_wait_1): Avoid setting need_step_over is there's a GDB breakpoint at stop_pc. Always report a trap to GDB if we could tell there's a GDB breakpoint at stop_pc. (need_step_over_p): Don't do a step over if we find a GDB breakpoint at the resume PC. * mem-break.c (struct raw_breakpoint): New. (enum bkpt_type): New type `gdb_breakpoint'. (struct breakpoint): Delete the `PC', `old_data' and `inserted' fields. New field `raw'. (find_raw_breakpoint_at): New. (set_raw_breakpoint_at): Handle refcounting. Create a raw breakpoint instead. (set_breakpoint_at): Adjust. (delete_raw_breakpoint): New. (release_breakpoint): New. (delete_breakpoint): Rename to... (delete_breakpoint_1): ... this. Add proc parameter. Use release_breakpoint. Return ENOENT. (delete_breakpoint): Reimplement. (find_breakpoint_at): Delete. (find_gdb_breakpoint_at): New. (delete_breakpoint_at): Delete. (set_gdb_breakpoint_at): New. (delete_gdb_breakpoint_at): New. (gdb_breakpoint_here): New. (set_reinsert_breakpoint): Use release_breakpoint. (uninsert_breakpoint): Rename to ... (uninsert_raw_breakpoint): ... this. (uninsert_breakpoints_at): Adjust to handle raw breakpoints. (reinsert_raw_breakpoint): Change parameter type to raw_breakpoint. (reinsert_breakpoints_at): Adjust to handle raw breakpoints instead. (check_breakpoints): Adjust. Use release_breakpoint. (breakpoint_here): Rewrite using find_raw_breakpoint_at. (breakpoint_inserted_here): Ditto. (check_mem_read): Adjust to iterate over raw breakpoints instead. Don't trust the breakpoint's shadow if it is not inserted. (check_mem_write): Adjust to iterate over raw breakpoints instead. (delete_all_breakpoints): Adjust. (free_all_breakpoints): Mark all breakpoints as uninserted, and use delete_breakpoint_1. * mem-break.h (breakpoints_supported): Delete declaration. (set_gdb_breakpoint_at): Declare. (gdb_breakpoint_here): Declare. (delete_breakpoint_at): Delete. (delete_gdb_breakpoint_at): Declare. * server.h (struct raw_breakpoint): Forward declare. (struct process_info): New field `raw_breakpoints'. * linux-x86-low.c (x86_insert_point, x86_remote_point): Handle Z0 breakpoints.
2010-04-01 16:25:34 +02:00
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Need step over [LWP %ld]? yes, but found"
" GDB breakpoint at 0x%s; skipping step over\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
lwpid_of (thread), paddress (pc));
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
current_thread = saved_thread;
return false;
* linux-low.c (linux_wait_1): Avoid setting need_step_over is there's a GDB breakpoint at stop_pc. Always report a trap to GDB if we could tell there's a GDB breakpoint at stop_pc. (need_step_over_p): Don't do a step over if we find a GDB breakpoint at the resume PC. * mem-break.c (struct raw_breakpoint): New. (enum bkpt_type): New type `gdb_breakpoint'. (struct breakpoint): Delete the `PC', `old_data' and `inserted' fields. New field `raw'. (find_raw_breakpoint_at): New. (set_raw_breakpoint_at): Handle refcounting. Create a raw breakpoint instead. (set_breakpoint_at): Adjust. (delete_raw_breakpoint): New. (release_breakpoint): New. (delete_breakpoint): Rename to... (delete_breakpoint_1): ... this. Add proc parameter. Use release_breakpoint. Return ENOENT. (delete_breakpoint): Reimplement. (find_breakpoint_at): Delete. (find_gdb_breakpoint_at): New. (delete_breakpoint_at): Delete. (set_gdb_breakpoint_at): New. (delete_gdb_breakpoint_at): New. (gdb_breakpoint_here): New. (set_reinsert_breakpoint): Use release_breakpoint. (uninsert_breakpoint): Rename to ... (uninsert_raw_breakpoint): ... this. (uninsert_breakpoints_at): Adjust to handle raw breakpoints. (reinsert_raw_breakpoint): Change parameter type to raw_breakpoint. (reinsert_breakpoints_at): Adjust to handle raw breakpoints instead. (check_breakpoints): Adjust. Use release_breakpoint. (breakpoint_here): Rewrite using find_raw_breakpoint_at. (breakpoint_inserted_here): Ditto. (check_mem_read): Adjust to iterate over raw breakpoints instead. Don't trust the breakpoint's shadow if it is not inserted. (check_mem_write): Adjust to iterate over raw breakpoints instead. (delete_all_breakpoints): Adjust. (free_all_breakpoints): Mark all breakpoints as uninserted, and use delete_breakpoint_1. * mem-break.h (breakpoints_supported): Delete declaration. (set_gdb_breakpoint_at): Declare. (gdb_breakpoint_here): Declare. (delete_breakpoint_at): Delete. (delete_gdb_breakpoint_at): Declare. * server.h (struct raw_breakpoint): Forward declare. (struct process_info): New field `raw_breakpoints'. * linux-x86-low.c (x86_insert_point, x86_remote_point): Handle Z0 breakpoints.
2010-04-01 16:25:34 +02:00
}
else
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Need step over [LWP %ld]? yes, "
"found breakpoint at 0x%s\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
lwpid_of (thread), paddress (pc));
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
* linux-low.c (linux_wait_1): Avoid setting need_step_over is there's a GDB breakpoint at stop_pc. Always report a trap to GDB if we could tell there's a GDB breakpoint at stop_pc. (need_step_over_p): Don't do a step over if we find a GDB breakpoint at the resume PC. * mem-break.c (struct raw_breakpoint): New. (enum bkpt_type): New type `gdb_breakpoint'. (struct breakpoint): Delete the `PC', `old_data' and `inserted' fields. New field `raw'. (find_raw_breakpoint_at): New. (set_raw_breakpoint_at): Handle refcounting. Create a raw breakpoint instead. (set_breakpoint_at): Adjust. (delete_raw_breakpoint): New. (release_breakpoint): New. (delete_breakpoint): Rename to... (delete_breakpoint_1): ... this. Add proc parameter. Use release_breakpoint. Return ENOENT. (delete_breakpoint): Reimplement. (find_breakpoint_at): Delete. (find_gdb_breakpoint_at): New. (delete_breakpoint_at): Delete. (set_gdb_breakpoint_at): New. (delete_gdb_breakpoint_at): New. (gdb_breakpoint_here): New. (set_reinsert_breakpoint): Use release_breakpoint. (uninsert_breakpoint): Rename to ... (uninsert_raw_breakpoint): ... this. (uninsert_breakpoints_at): Adjust to handle raw breakpoints. (reinsert_raw_breakpoint): Change parameter type to raw_breakpoint. (reinsert_breakpoints_at): Adjust to handle raw breakpoints instead. (check_breakpoints): Adjust. Use release_breakpoint. (breakpoint_here): Rewrite using find_raw_breakpoint_at. (breakpoint_inserted_here): Ditto. (check_mem_read): Adjust to iterate over raw breakpoints instead. Don't trust the breakpoint's shadow if it is not inserted. (check_mem_write): Adjust to iterate over raw breakpoints instead. (delete_all_breakpoints): Adjust. (free_all_breakpoints): Mark all breakpoints as uninserted, and use delete_breakpoint_1. * mem-break.h (breakpoints_supported): Delete declaration. (set_gdb_breakpoint_at): Declare. (gdb_breakpoint_here): Declare. (delete_breakpoint_at): Delete. (delete_gdb_breakpoint_at): Declare. * server.h (struct raw_breakpoint): Forward declare. (struct process_info): New field `raw_breakpoints'. * linux-x86-low.c (x86_insert_point, x86_remote_point): Handle Z0 breakpoints.
2010-04-01 16:25:34 +02:00
/* We've found an lwp that needs stepping over --- return 1 so
that find_thread stops looking. */
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
current_thread = saved_thread;
* linux-low.c (linux_wait_1): Avoid setting need_step_over is there's a GDB breakpoint at stop_pc. Always report a trap to GDB if we could tell there's a GDB breakpoint at stop_pc. (need_step_over_p): Don't do a step over if we find a GDB breakpoint at the resume PC. * mem-break.c (struct raw_breakpoint): New. (enum bkpt_type): New type `gdb_breakpoint'. (struct breakpoint): Delete the `PC', `old_data' and `inserted' fields. New field `raw'. (find_raw_breakpoint_at): New. (set_raw_breakpoint_at): Handle refcounting. Create a raw breakpoint instead. (set_breakpoint_at): Adjust. (delete_raw_breakpoint): New. (release_breakpoint): New. (delete_breakpoint): Rename to... (delete_breakpoint_1): ... this. Add proc parameter. Use release_breakpoint. Return ENOENT. (delete_breakpoint): Reimplement. (find_breakpoint_at): Delete. (find_gdb_breakpoint_at): New. (delete_breakpoint_at): Delete. (set_gdb_breakpoint_at): New. (delete_gdb_breakpoint_at): New. (gdb_breakpoint_here): New. (set_reinsert_breakpoint): Use release_breakpoint. (uninsert_breakpoint): Rename to ... (uninsert_raw_breakpoint): ... this. (uninsert_breakpoints_at): Adjust to handle raw breakpoints. (reinsert_raw_breakpoint): Change parameter type to raw_breakpoint. (reinsert_breakpoints_at): Adjust to handle raw breakpoints instead. (check_breakpoints): Adjust. Use release_breakpoint. (breakpoint_here): Rewrite using find_raw_breakpoint_at. (breakpoint_inserted_here): Ditto. (check_mem_read): Adjust to iterate over raw breakpoints instead. Don't trust the breakpoint's shadow if it is not inserted. (check_mem_write): Adjust to iterate over raw breakpoints instead. (delete_all_breakpoints): Adjust. (free_all_breakpoints): Mark all breakpoints as uninserted, and use delete_breakpoint_1. * mem-break.h (breakpoints_supported): Delete declaration. (set_gdb_breakpoint_at): Declare. (gdb_breakpoint_here): Declare. (delete_breakpoint_at): Delete. (delete_gdb_breakpoint_at): Declare. * server.h (struct raw_breakpoint): Forward declare. (struct process_info): New field `raw_breakpoints'. * linux-x86-low.c (x86_insert_point, x86_remote_point): Handle Z0 breakpoints.
2010-04-01 16:25:34 +02:00
return true;
* linux-low.c (linux_wait_1): Avoid setting need_step_over is there's a GDB breakpoint at stop_pc. Always report a trap to GDB if we could tell there's a GDB breakpoint at stop_pc. (need_step_over_p): Don't do a step over if we find a GDB breakpoint at the resume PC. * mem-break.c (struct raw_breakpoint): New. (enum bkpt_type): New type `gdb_breakpoint'. (struct breakpoint): Delete the `PC', `old_data' and `inserted' fields. New field `raw'. (find_raw_breakpoint_at): New. (set_raw_breakpoint_at): Handle refcounting. Create a raw breakpoint instead. (set_breakpoint_at): Adjust. (delete_raw_breakpoint): New. (release_breakpoint): New. (delete_breakpoint): Rename to... (delete_breakpoint_1): ... this. Add proc parameter. Use release_breakpoint. Return ENOENT. (delete_breakpoint): Reimplement. (find_breakpoint_at): Delete. (find_gdb_breakpoint_at): New. (delete_breakpoint_at): Delete. (set_gdb_breakpoint_at): New. (delete_gdb_breakpoint_at): New. (gdb_breakpoint_here): New. (set_reinsert_breakpoint): Use release_breakpoint. (uninsert_breakpoint): Rename to ... (uninsert_raw_breakpoint): ... this. (uninsert_breakpoints_at): Adjust to handle raw breakpoints. (reinsert_raw_breakpoint): Change parameter type to raw_breakpoint. (reinsert_breakpoints_at): Adjust to handle raw breakpoints instead. (check_breakpoints): Adjust. Use release_breakpoint. (breakpoint_here): Rewrite using find_raw_breakpoint_at. (breakpoint_inserted_here): Ditto. (check_mem_read): Adjust to iterate over raw breakpoints instead. Don't trust the breakpoint's shadow if it is not inserted. (check_mem_write): Adjust to iterate over raw breakpoints instead. (delete_all_breakpoints): Adjust. (free_all_breakpoints): Mark all breakpoints as uninserted, and use delete_breakpoint_1. * mem-break.h (breakpoints_supported): Delete declaration. (set_gdb_breakpoint_at): Declare. (gdb_breakpoint_here): Declare. (delete_breakpoint_at): Delete. (delete_gdb_breakpoint_at): Declare. * server.h (struct raw_breakpoint): Forward declare. (struct process_info): New field `raw_breakpoints'. * linux-x86-low.c (x86_insert_point, x86_remote_point): Handle Z0 breakpoints.
2010-04-01 16:25:34 +02:00
}
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
}
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
current_thread = saved_thread;
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Need step over [LWP %ld]? No, no breakpoint found"
" at 0x%s\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
lwpid_of (thread), paddress (pc));
return false;
}
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
void
linux_process_target::start_step_over (lwp_info *lwp)
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
{
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
struct thread_info *thread = get_lwp_thread (lwp);
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
struct thread_info *saved_thread;
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
CORE_ADDR pc;
int step;
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Starting step-over on LWP %ld. Stopping all threads\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
lwpid_of (thread));
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
stop_all_lwps (1, lwp);
gdbserver: Fix non-stop / fork / step-over issues Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html This adds a test that has a multithreaded program have several threads continuously fork, while another thread continuously steps over a breakpoint. This exposes several intertwined issues, which this patch addresses: - When we're stopping and suspending threads, some thread may fork, and we missed setting its suspend count to 1, like we do when a new clone/thread is detected. When we next unsuspend threads, the fork child's suspend count goes below 0, which is bogus and fails an assertion. - If a step-over is cancelled because a signal arrives, but then gdb is not interested in the signal, we pass the signal straight back to the inferior. However, we miss that we need to re-increment the suspend counts of all other threads that had been paused for the step-over. As a result, other threads indefinitely end up stuck stopped. - If a detach request comes in just while gdbserver is handling a step-over (in the test at hand, this is GDB detaching the fork child), gdbserver internal errors in stabilize_thread's helpers, which assert that all thread's suspend counts are 0 (otherwise we wouldn't be able to move threads out of the jump pads). The suspend counts aren't 0 while a step-over is in progress, because all threads but the one stepping past the breakpoint must remain paused until the step-over finishes and the breakpoint can be reinserted. - Occasionally, we see "BAD - reinserting but not stepping." being output (from within linux_resume_one_lwp_throw). That was because GDB pokes memory while gdbserver is busy with a step-over, and that suspends threads, and then re-resumes them with proceed_one_lwp, which missed another reason to tell linux_resume_one_lwp that the thread should be set back to stepping. - In a couple places, we were resuming threads that are meant to be suspended. E.g., when a vCont;c/s request for thread B comes in just while gdbserver is stepping thread A past a breakpoint. The resume for thread B must be deferred until the step-over finishes. - The test runs with both "set detach-on-fork" on and off. When off, it exercises the case of GDB detaching the fork child explicitly. When on, it exercises the case of gdb resuming the child explicitly. In the "off" case, gdb seems to exponentially become slower as new inferiors are created. This is _very_ noticeable as with only 100 inferiors gdb is crawling already, which makes the test take quite a bit to run. For that reason, I've disabled the "off" variant for now. gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * target/waitstatus.h (enum target_stop_reason) <TARGET_STOPPED_BY_SINGLE_STEP>: New value. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the fork child's suspend count if stopping and suspending threads. (check_stopped_by_breakpoint): If stopped by trace, set the LWP's stop reason to TARGET_STOPPED_BY_SINGLE_STEP. (linux_detach): Complete an ongoing step-over. (lwp_suspended_inc, lwp_suspended_decr): New functions. Use throughout. (resume_stopped_resumed_lwps): Don't resume a suspended thread. (linux_wait_1): If passing a signal to the inferior after finishing a step-over, unsuspend and re-resume all lwps. If we see a single-step event but the thread should be continuing, don't pass the trap to gdb. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use internal_error instead of gdb_assert. (enqueue_pending_signal): New function. (check_ptrace_stopped_lwp_gone): Add debug output. (start_step_over): Use internal_error instead of gdb_assert. (complete_ongoing_step_over): New function. (linux_resume_one_thread): Don't resume a suspended thread. (proceed_one_lwp): If the LWP is stepping over a breakpoint, reset it stepping. gdb/testsuite/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * gdb.threads/forking-threads-plus-breakpoint.exp: New file. * gdb.threads/forking-threads-plus-breakpoint.c: New file.
2015-08-06 11:30:18 +02:00
if (lwp->suspended != 0)
{
internal_error (__FILE__, __LINE__,
"LWP %ld suspended=%d\n", lwpid_of (thread),
lwp->suspended);
}
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Done stopping all threads for step-over.\n");
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
/* Note, we should always reach here with an already adjusted PC,
either by GDB (if we're resuming due to GDB's request), or by our
caller, if we just finished handling an internal breakpoint GDB
shouldn't care about. */
pc = get_pc (lwp);
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
saved_thread = current_thread;
current_thread = thread;
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
lwp->bp_reinsert = pc;
uninsert_breakpoints_at (pc);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
uninsert_fast_tracepoint_jumps_at (pc);
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
step = single_step (lwp);
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
current_thread = saved_thread;
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
resume_one_lwp (lwp, step, 0, NULL);
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
/* Require next event from this LWP. */
gdbserver: use std::list for all_threads Remove the usage of inferior_list for the all_threads list in gdbserver. The entry field in thread_info is removed, and replaced by a simple ptid field. I added some functions to iterate (for_each_thread) and find threads (find_thread). However, changing all the users of find_inferior & co to use these new functions would have made the patch way too big. So I opted instead to make find_inferior & co some shims, so that the existing code only needs to be updated minimally. We can then update the existing code to use the new functions incrementally (I've started to do the work, but I'll post it afterwards, see [1] if you want a peek). This patch has been built-tested on all relevant platforms, except lynx. I also regtested using the native-gdbserver and native-extended-gdbserver boards on x86. [1] https://github.com/simark/binutils-gdb/commits/kill-inferior-list-entry gdb/gdbserver/ChangeLog: * inferiors.h: (struct inferior_list): Remove. (struct inferior_list_entry); Remove. (add_inferior_to_list, clear_inferior_list, one_inferior_p, A_I_NEXT, ALL_INFERIORS_TYPE, ALL_INFERIORS, remove_inferior, get_first_inferior): Remove. (for_each_inferior, for_each_inferior_with_data, find_inferior, find_inferior_id, find_inferior_in_random): Change signature. * inferiors.c (all_threads): Change type to std::list<thread_info *>. (get_thread): Remove macro. (find_inferior, find_inferior_id): Change signature, implement using find_thread. (find_inferior_in_random): Change signature, implement using find_thread_in_random. (for_each_inferior, for_each_inferior_with_data): Change signature, implement using for_each_thread. (add_inferior_to_list, remove_inferior): Remove. (add_thread, get_first_thread, thread_of_pid, find_any_thread_of_pid, free_one_thread, remove_thread): Update. (get_first_inferior, one_inferior_p, clear_inferior_list): Remove. (clear_inferiors, get_thread_process): Update. * gdbthread.h: Include <list>. (struct thread_info) <entry>: Remove field. <id>: New field. (all_threads): Change type to std::list<thread_info *>. (get_first_inferior): Add doc. (find_thread, for_each_thread, find_thread_in_random): New functions. (current_ptid, pid_of, ptid_of, lwpid_of): Update. * linux-arm-low.c (update_registers_callback): Update. * linux-low.c (second_thread_of_pid_p): Update. (kill_one_lwp_callback, linux_detach_lwp_callback, delete_lwp_callback, status_pending_p_callback, same_lwp, find_lwp_pid, num_lwps, iterate_over_lwps_filter, iterate_over_lwps, not_stopped_callback, resume_stopped_resumed_lwps, count_events_callback, select_singlestep_lwp_callback, select_event_lwp_callback, unsuspend_one_lwp, linux_wait_1, send_sigstop_callback, suspend_and_send_sigstop_callback, wait_for_sigstop, stuck_in_jump_pad_callback, move_out_of_jump_pad_callback, lwp_running, linux_set_resume_request, resume_status_pending_p, need_step_over_p, start_step_over, linux_resume_one_thread, proceed_one_lwp, unsuspend_and_proceed_one_lwp, reset_lwp_ptrace_options_callback): Update. * linux-mips-low.c (update_watch_registers_callback): Update. * regcache.c (regcache_invalidate_one, regcache_invalidate): Update. (free_register_cache_thread_one): Remove. (regcache_release): Update. * server.c (handle_btrace_enable_bts, handle_btrace_enable_pt, handle_qxfer_threads_worker): Update. (handle_query): Update, use list iterator. (visit_actioned_threads, handle_pending_status, queue_stop_reply_callback, gdb_wants_all_threads_stopped, clear_pending_status_callback, set_pending_status_callback, find_status_pending_thread_callback, handle_status, process_serial_event): Update. * target.c (thread_search_callback): Update. * thread-db.c (thread_db_get_tls_address): Update. * tracepoint.c (tracepoint_finished_step, tracepoint_was_hit): Update. * win32-i386-low.c (update_debug_registers_callback): Update. * win32-low.c (delete_thread_info, child_delete_thread, continue_one_thread, suspend_one_thread, get_child_debug_event): Adjust.
2017-10-14 15:11:12 +02:00
step_over_bkpt = thread->id;
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
}
gdbserver/linux-low: turn 'supports_hardware_single_step' into a method All the linux low targets except arm define the 'supports_hardware_single_step' op to return true. Hence, we override the method to return true in linux_process_target, and remove the definitions in all the linux low targets but arm. gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Remove the 'supports_hardware_single_step' linux target op and override the process_stratum_target's op definition in linux_process_target to return true. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <finish_step_over> <maybe_hw_step>: Declare. * linux-low.cc (can_hardware_single_step): Remove. (maybe_hw_step): Turn into... (linux_process_target::maybe_hw_step): ...this. (finish_step_over): Turn into... (linux_process_target::finish_step_over): ...this. (linux_process_target::supports_hardware_single_step): Update to return true. Update the callers below. (linux_process_target::single_step) (linux_process_target::resume_one_lwp_throw) * linux-arm-low.cc (class arm_target) <supports_hardware_single_step>: Declare. (arm_supports_hardware_single_step): Turn into... (arm_target::supports_hardware_single_step): ...this. (the_low_target): Remove the op field. * linux-x86-low.cc (x86_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-aarch64-low.cc (aarch64_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-bfin-low.cc (bfin_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-crisv32-low.cc (cris_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-m32r-low.cc (m32r_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-m68k-low.cc (m68k_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-ppc-low.cc (ppc_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-s390-low.cc (s390_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-sh-low.cc (sh_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-tic6x-low.cc (tic6x_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-tile-low.cc (tile_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-xtensa-low.cc (xtensa_supports_hardware_single_step): Remove. (the_low_target): Remove the op field.
2020-04-02 15:11:31 +02:00
bool
linux_process_target::finish_step_over (lwp_info *lwp)
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
{
if (lwp->bp_reinsert != 0)
{
Switch to current thread in finish_step_over This patch adds some sanity check that reinsert breakpoints must be there when doing step-over on software single step target. The check triggers an assert when running forking-threads-plus-breakpoint.exp on arm-linux target, gdb/gdbserver/linux-low.c:4714: A problem internal to GDBserver has been detected.^M int finish_step_over(lwp_info*): Assertion `has_reinsert_breakpoints ()' failed. the error happens when GDBserver has already resumed a thread of process A for step-over (and wait for it hitting reinsert breakpoint), but receives detach request for process B from GDB, which is shown in the backtrace below, (gdb) bt #2 0x000228aa in finish_step_over (lwp=0x12bbd98) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4703 #3 0x00025a50 in finish_step_over (lwp=0x12bbd98) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4749 #4 complete_ongoing_step_over () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4760 #5 linux_detach (pid=25228) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:1503 #6 0x00012bae in process_serial_event () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3974 #7 handle_serial_event (err=<optimized out>, client_data=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:4347 #8 0x00016d68 in handle_file_event (event_file_desc=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:429 #9 0x000173ea in process_event () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:184 #10 start_event_loop () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:547 #11 0x0000aa2c in captured_main (argv=<optimized out>, argc=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3719 #12 main (argc=<optimized out>, argv=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3804 the sanity check tries to find the reinsert breakpoint from process B, but nothing is found. It is wrong, we need to search in process A, since we started step-over of a thread of process A. (gdb) p lwp->thread->entry.id $3 = {pid = 25120, lwp = 25131, tid = 0} (gdb) p current_thread->entry.id $4 = {pid = 25228, lwp = 25228, tid = 0} This patch switched current_thread to the thread we are doing step-over in finish_step_over. gdb/gdbserver: 2016-06-17 Yao Qi <yao.qi@linaro.org> * linux-low.c (maybe_hw_step): New function. (linux_resume_one_lwp_throw): Call maybe_hw_step. (finish_step_over): Switch current_thread to lwp temporarily, and assert has_reinsert_breakpoints returns true. (proceed_one_lwp): Call maybe_hw_step. * mem-break.c (has_reinsert_breakpoints): New function. * mem-break.h (has_reinsert_breakpoints): Declare.
2016-06-17 11:25:12 +02:00
struct thread_info *saved_thread = current_thread;
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Finished step over.\n");
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
Switch to current thread in finish_step_over This patch adds some sanity check that reinsert breakpoints must be there when doing step-over on software single step target. The check triggers an assert when running forking-threads-plus-breakpoint.exp on arm-linux target, gdb/gdbserver/linux-low.c:4714: A problem internal to GDBserver has been detected.^M int finish_step_over(lwp_info*): Assertion `has_reinsert_breakpoints ()' failed. the error happens when GDBserver has already resumed a thread of process A for step-over (and wait for it hitting reinsert breakpoint), but receives detach request for process B from GDB, which is shown in the backtrace below, (gdb) bt #2 0x000228aa in finish_step_over (lwp=0x12bbd98) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4703 #3 0x00025a50 in finish_step_over (lwp=0x12bbd98) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4749 #4 complete_ongoing_step_over () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4760 #5 linux_detach (pid=25228) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:1503 #6 0x00012bae in process_serial_event () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3974 #7 handle_serial_event (err=<optimized out>, client_data=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:4347 #8 0x00016d68 in handle_file_event (event_file_desc=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:429 #9 0x000173ea in process_event () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:184 #10 start_event_loop () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:547 #11 0x0000aa2c in captured_main (argv=<optimized out>, argc=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3719 #12 main (argc=<optimized out>, argv=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3804 the sanity check tries to find the reinsert breakpoint from process B, but nothing is found. It is wrong, we need to search in process A, since we started step-over of a thread of process A. (gdb) p lwp->thread->entry.id $3 = {pid = 25120, lwp = 25131, tid = 0} (gdb) p current_thread->entry.id $4 = {pid = 25228, lwp = 25228, tid = 0} This patch switched current_thread to the thread we are doing step-over in finish_step_over. gdb/gdbserver: 2016-06-17 Yao Qi <yao.qi@linaro.org> * linux-low.c (maybe_hw_step): New function. (linux_resume_one_lwp_throw): Call maybe_hw_step. (finish_step_over): Switch current_thread to lwp temporarily, and assert has_reinsert_breakpoints returns true. (proceed_one_lwp): Call maybe_hw_step. * mem-break.c (has_reinsert_breakpoints): New function. * mem-break.h (has_reinsert_breakpoints): Declare.
2016-06-17 11:25:12 +02:00
current_thread = get_lwp_thread (lwp);
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
/* Reinsert any breakpoint at LWP->BP_REINSERT. Note that there
may be no breakpoint to reinsert there by now. */
reinsert_breakpoints_at (lwp->bp_reinsert);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
reinsert_fast_tracepoint_jumps_at (lwp->bp_reinsert);
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
lwp->bp_reinsert = 0;
/* Delete any single-step breakpoints. No longer needed. We
don't have to worry about other threads hitting this trap,
and later not being able to explain it, because we were
stepping over a breakpoint, and we hold all threads but
LWP stopped while doing that. */
gdbserver/linux-low: turn 'supports_hardware_single_step' into a method All the linux low targets except arm define the 'supports_hardware_single_step' op to return true. Hence, we override the method to return true in linux_process_target, and remove the definitions in all the linux low targets but arm. gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Remove the 'supports_hardware_single_step' linux target op and override the process_stratum_target's op definition in linux_process_target to return true. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <finish_step_over> <maybe_hw_step>: Declare. * linux-low.cc (can_hardware_single_step): Remove. (maybe_hw_step): Turn into... (linux_process_target::maybe_hw_step): ...this. (finish_step_over): Turn into... (linux_process_target::finish_step_over): ...this. (linux_process_target::supports_hardware_single_step): Update to return true. Update the callers below. (linux_process_target::single_step) (linux_process_target::resume_one_lwp_throw) * linux-arm-low.cc (class arm_target) <supports_hardware_single_step>: Declare. (arm_supports_hardware_single_step): Turn into... (arm_target::supports_hardware_single_step): ...this. (the_low_target): Remove the op field. * linux-x86-low.cc (x86_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-aarch64-low.cc (aarch64_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-bfin-low.cc (bfin_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-crisv32-low.cc (cris_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-m32r-low.cc (m32r_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-m68k-low.cc (m68k_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-ppc-low.cc (ppc_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-s390-low.cc (s390_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-sh-low.cc (sh_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-tic6x-low.cc (tic6x_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-tile-low.cc (tile_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-xtensa-low.cc (xtensa_supports_hardware_single_step): Remove. (the_low_target): Remove the op field.
2020-04-02 15:11:31 +02:00
if (!supports_hardware_single_step ())
Switch to current thread in finish_step_over This patch adds some sanity check that reinsert breakpoints must be there when doing step-over on software single step target. The check triggers an assert when running forking-threads-plus-breakpoint.exp on arm-linux target, gdb/gdbserver/linux-low.c:4714: A problem internal to GDBserver has been detected.^M int finish_step_over(lwp_info*): Assertion `has_reinsert_breakpoints ()' failed. the error happens when GDBserver has already resumed a thread of process A for step-over (and wait for it hitting reinsert breakpoint), but receives detach request for process B from GDB, which is shown in the backtrace below, (gdb) bt #2 0x000228aa in finish_step_over (lwp=0x12bbd98) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4703 #3 0x00025a50 in finish_step_over (lwp=0x12bbd98) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4749 #4 complete_ongoing_step_over () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4760 #5 linux_detach (pid=25228) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:1503 #6 0x00012bae in process_serial_event () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3974 #7 handle_serial_event (err=<optimized out>, client_data=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:4347 #8 0x00016d68 in handle_file_event (event_file_desc=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:429 #9 0x000173ea in process_event () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:184 #10 start_event_loop () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:547 #11 0x0000aa2c in captured_main (argv=<optimized out>, argc=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3719 #12 main (argc=<optimized out>, argv=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3804 the sanity check tries to find the reinsert breakpoint from process B, but nothing is found. It is wrong, we need to search in process A, since we started step-over of a thread of process A. (gdb) p lwp->thread->entry.id $3 = {pid = 25120, lwp = 25131, tid = 0} (gdb) p current_thread->entry.id $4 = {pid = 25228, lwp = 25228, tid = 0} This patch switched current_thread to the thread we are doing step-over in finish_step_over. gdb/gdbserver: 2016-06-17 Yao Qi <yao.qi@linaro.org> * linux-low.c (maybe_hw_step): New function. (linux_resume_one_lwp_throw): Call maybe_hw_step. (finish_step_over): Switch current_thread to lwp temporarily, and assert has_reinsert_breakpoints returns true. (proceed_one_lwp): Call maybe_hw_step. * mem-break.c (has_reinsert_breakpoints): New function. * mem-break.h (has_reinsert_breakpoints): Declare.
2016-06-17 11:25:12 +02:00
{
gdb_assert (has_single_step_breakpoints (current_thread));
delete_single_step_breakpoints (current_thread);
Switch to current thread in finish_step_over This patch adds some sanity check that reinsert breakpoints must be there when doing step-over on software single step target. The check triggers an assert when running forking-threads-plus-breakpoint.exp on arm-linux target, gdb/gdbserver/linux-low.c:4714: A problem internal to GDBserver has been detected.^M int finish_step_over(lwp_info*): Assertion `has_reinsert_breakpoints ()' failed. the error happens when GDBserver has already resumed a thread of process A for step-over (and wait for it hitting reinsert breakpoint), but receives detach request for process B from GDB, which is shown in the backtrace below, (gdb) bt #2 0x000228aa in finish_step_over (lwp=0x12bbd98) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4703 #3 0x00025a50 in finish_step_over (lwp=0x12bbd98) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4749 #4 complete_ongoing_step_over () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4760 #5 linux_detach (pid=25228) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:1503 #6 0x00012bae in process_serial_event () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3974 #7 handle_serial_event (err=<optimized out>, client_data=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:4347 #8 0x00016d68 in handle_file_event (event_file_desc=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:429 #9 0x000173ea in process_event () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:184 #10 start_event_loop () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:547 #11 0x0000aa2c in captured_main (argv=<optimized out>, argc=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3719 #12 main (argc=<optimized out>, argv=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3804 the sanity check tries to find the reinsert breakpoint from process B, but nothing is found. It is wrong, we need to search in process A, since we started step-over of a thread of process A. (gdb) p lwp->thread->entry.id $3 = {pid = 25120, lwp = 25131, tid = 0} (gdb) p current_thread->entry.id $4 = {pid = 25228, lwp = 25228, tid = 0} This patch switched current_thread to the thread we are doing step-over in finish_step_over. gdb/gdbserver: 2016-06-17 Yao Qi <yao.qi@linaro.org> * linux-low.c (maybe_hw_step): New function. (linux_resume_one_lwp_throw): Call maybe_hw_step. (finish_step_over): Switch current_thread to lwp temporarily, and assert has_reinsert_breakpoints returns true. (proceed_one_lwp): Call maybe_hw_step. * mem-break.c (has_reinsert_breakpoints): New function. * mem-break.h (has_reinsert_breakpoints): Declare.
2016-06-17 11:25:12 +02:00
}
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
step_over_bkpt = null_ptid;
Switch to current thread in finish_step_over This patch adds some sanity check that reinsert breakpoints must be there when doing step-over on software single step target. The check triggers an assert when running forking-threads-plus-breakpoint.exp on arm-linux target, gdb/gdbserver/linux-low.c:4714: A problem internal to GDBserver has been detected.^M int finish_step_over(lwp_info*): Assertion `has_reinsert_breakpoints ()' failed. the error happens when GDBserver has already resumed a thread of process A for step-over (and wait for it hitting reinsert breakpoint), but receives detach request for process B from GDB, which is shown in the backtrace below, (gdb) bt #2 0x000228aa in finish_step_over (lwp=0x12bbd98) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4703 #3 0x00025a50 in finish_step_over (lwp=0x12bbd98) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4749 #4 complete_ongoing_step_over () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4760 #5 linux_detach (pid=25228) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:1503 #6 0x00012bae in process_serial_event () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3974 #7 handle_serial_event (err=<optimized out>, client_data=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:4347 #8 0x00016d68 in handle_file_event (event_file_desc=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:429 #9 0x000173ea in process_event () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:184 #10 start_event_loop () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:547 #11 0x0000aa2c in captured_main (argv=<optimized out>, argc=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3719 #12 main (argc=<optimized out>, argv=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3804 the sanity check tries to find the reinsert breakpoint from process B, but nothing is found. It is wrong, we need to search in process A, since we started step-over of a thread of process A. (gdb) p lwp->thread->entry.id $3 = {pid = 25120, lwp = 25131, tid = 0} (gdb) p current_thread->entry.id $4 = {pid = 25228, lwp = 25228, tid = 0} This patch switched current_thread to the thread we are doing step-over in finish_step_over. gdb/gdbserver: 2016-06-17 Yao Qi <yao.qi@linaro.org> * linux-low.c (maybe_hw_step): New function. (linux_resume_one_lwp_throw): Call maybe_hw_step. (finish_step_over): Switch current_thread to lwp temporarily, and assert has_reinsert_breakpoints returns true. (proceed_one_lwp): Call maybe_hw_step. * mem-break.c (has_reinsert_breakpoints): New function. * mem-break.h (has_reinsert_breakpoints): Declare.
2016-06-17 11:25:12 +02:00
current_thread = saved_thread;
gdbserver/linux-low: turn 'supports_hardware_single_step' into a method All the linux low targets except arm define the 'supports_hardware_single_step' op to return true. Hence, we override the method to return true in linux_process_target, and remove the definitions in all the linux low targets but arm. gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Remove the 'supports_hardware_single_step' linux target op and override the process_stratum_target's op definition in linux_process_target to return true. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <finish_step_over> <maybe_hw_step>: Declare. * linux-low.cc (can_hardware_single_step): Remove. (maybe_hw_step): Turn into... (linux_process_target::maybe_hw_step): ...this. (finish_step_over): Turn into... (linux_process_target::finish_step_over): ...this. (linux_process_target::supports_hardware_single_step): Update to return true. Update the callers below. (linux_process_target::single_step) (linux_process_target::resume_one_lwp_throw) * linux-arm-low.cc (class arm_target) <supports_hardware_single_step>: Declare. (arm_supports_hardware_single_step): Turn into... (arm_target::supports_hardware_single_step): ...this. (the_low_target): Remove the op field. * linux-x86-low.cc (x86_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-aarch64-low.cc (aarch64_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-bfin-low.cc (bfin_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-crisv32-low.cc (cris_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-m32r-low.cc (m32r_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-m68k-low.cc (m68k_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-ppc-low.cc (ppc_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-s390-low.cc (s390_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-sh-low.cc (sh_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-tic6x-low.cc (tic6x_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-tile-low.cc (tile_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-xtensa-low.cc (xtensa_supports_hardware_single_step): Remove. (the_low_target): Remove the op field.
2020-04-02 15:11:31 +02:00
return true;
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
}
else
gdbserver/linux-low: turn 'supports_hardware_single_step' into a method All the linux low targets except arm define the 'supports_hardware_single_step' op to return true. Hence, we override the method to return true in linux_process_target, and remove the definitions in all the linux low targets but arm. gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Remove the 'supports_hardware_single_step' linux target op and override the process_stratum_target's op definition in linux_process_target to return true. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <finish_step_over> <maybe_hw_step>: Declare. * linux-low.cc (can_hardware_single_step): Remove. (maybe_hw_step): Turn into... (linux_process_target::maybe_hw_step): ...this. (finish_step_over): Turn into... (linux_process_target::finish_step_over): ...this. (linux_process_target::supports_hardware_single_step): Update to return true. Update the callers below. (linux_process_target::single_step) (linux_process_target::resume_one_lwp_throw) * linux-arm-low.cc (class arm_target) <supports_hardware_single_step>: Declare. (arm_supports_hardware_single_step): Turn into... (arm_target::supports_hardware_single_step): ...this. (the_low_target): Remove the op field. * linux-x86-low.cc (x86_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-aarch64-low.cc (aarch64_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-bfin-low.cc (bfin_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-crisv32-low.cc (cris_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-m32r-low.cc (m32r_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-m68k-low.cc (m68k_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-ppc-low.cc (ppc_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-s390-low.cc (s390_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-sh-low.cc (sh_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-tic6x-low.cc (tic6x_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-tile-low.cc (tile_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-xtensa-low.cc (xtensa_supports_hardware_single_step): Remove. (the_low_target): Remove the op field.
2020-04-02 15:11:31 +02:00
return false;
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
}
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
void
linux_process_target::complete_ongoing_step_over ()
gdbserver: Fix non-stop / fork / step-over issues Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html This adds a test that has a multithreaded program have several threads continuously fork, while another thread continuously steps over a breakpoint. This exposes several intertwined issues, which this patch addresses: - When we're stopping and suspending threads, some thread may fork, and we missed setting its suspend count to 1, like we do when a new clone/thread is detected. When we next unsuspend threads, the fork child's suspend count goes below 0, which is bogus and fails an assertion. - If a step-over is cancelled because a signal arrives, but then gdb is not interested in the signal, we pass the signal straight back to the inferior. However, we miss that we need to re-increment the suspend counts of all other threads that had been paused for the step-over. As a result, other threads indefinitely end up stuck stopped. - If a detach request comes in just while gdbserver is handling a step-over (in the test at hand, this is GDB detaching the fork child), gdbserver internal errors in stabilize_thread's helpers, which assert that all thread's suspend counts are 0 (otherwise we wouldn't be able to move threads out of the jump pads). The suspend counts aren't 0 while a step-over is in progress, because all threads but the one stepping past the breakpoint must remain paused until the step-over finishes and the breakpoint can be reinserted. - Occasionally, we see "BAD - reinserting but not stepping." being output (from within linux_resume_one_lwp_throw). That was because GDB pokes memory while gdbserver is busy with a step-over, and that suspends threads, and then re-resumes them with proceed_one_lwp, which missed another reason to tell linux_resume_one_lwp that the thread should be set back to stepping. - In a couple places, we were resuming threads that are meant to be suspended. E.g., when a vCont;c/s request for thread B comes in just while gdbserver is stepping thread A past a breakpoint. The resume for thread B must be deferred until the step-over finishes. - The test runs with both "set detach-on-fork" on and off. When off, it exercises the case of GDB detaching the fork child explicitly. When on, it exercises the case of gdb resuming the child explicitly. In the "off" case, gdb seems to exponentially become slower as new inferiors are created. This is _very_ noticeable as with only 100 inferiors gdb is crawling already, which makes the test take quite a bit to run. For that reason, I've disabled the "off" variant for now. gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * target/waitstatus.h (enum target_stop_reason) <TARGET_STOPPED_BY_SINGLE_STEP>: New value. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the fork child's suspend count if stopping and suspending threads. (check_stopped_by_breakpoint): If stopped by trace, set the LWP's stop reason to TARGET_STOPPED_BY_SINGLE_STEP. (linux_detach): Complete an ongoing step-over. (lwp_suspended_inc, lwp_suspended_decr): New functions. Use throughout. (resume_stopped_resumed_lwps): Don't resume a suspended thread. (linux_wait_1): If passing a signal to the inferior after finishing a step-over, unsuspend and re-resume all lwps. If we see a single-step event but the thread should be continuing, don't pass the trap to gdb. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use internal_error instead of gdb_assert. (enqueue_pending_signal): New function. (check_ptrace_stopped_lwp_gone): Add debug output. (start_step_over): Use internal_error instead of gdb_assert. (complete_ongoing_step_over): New function. (linux_resume_one_thread): Don't resume a suspended thread. (proceed_one_lwp): If the LWP is stepping over a breakpoint, reset it stepping. gdb/testsuite/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * gdb.threads/forking-threads-plus-breakpoint.exp: New file. * gdb.threads/forking-threads-plus-breakpoint.c: New file.
2015-08-06 11:30:18 +02:00
{
2018-06-11 22:45:22 +02:00
if (step_over_bkpt != null_ptid)
gdbserver: Fix non-stop / fork / step-over issues Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html This adds a test that has a multithreaded program have several threads continuously fork, while another thread continuously steps over a breakpoint. This exposes several intertwined issues, which this patch addresses: - When we're stopping and suspending threads, some thread may fork, and we missed setting its suspend count to 1, like we do when a new clone/thread is detected. When we next unsuspend threads, the fork child's suspend count goes below 0, which is bogus and fails an assertion. - If a step-over is cancelled because a signal arrives, but then gdb is not interested in the signal, we pass the signal straight back to the inferior. However, we miss that we need to re-increment the suspend counts of all other threads that had been paused for the step-over. As a result, other threads indefinitely end up stuck stopped. - If a detach request comes in just while gdbserver is handling a step-over (in the test at hand, this is GDB detaching the fork child), gdbserver internal errors in stabilize_thread's helpers, which assert that all thread's suspend counts are 0 (otherwise we wouldn't be able to move threads out of the jump pads). The suspend counts aren't 0 while a step-over is in progress, because all threads but the one stepping past the breakpoint must remain paused until the step-over finishes and the breakpoint can be reinserted. - Occasionally, we see "BAD - reinserting but not stepping." being output (from within linux_resume_one_lwp_throw). That was because GDB pokes memory while gdbserver is busy with a step-over, and that suspends threads, and then re-resumes them with proceed_one_lwp, which missed another reason to tell linux_resume_one_lwp that the thread should be set back to stepping. - In a couple places, we were resuming threads that are meant to be suspended. E.g., when a vCont;c/s request for thread B comes in just while gdbserver is stepping thread A past a breakpoint. The resume for thread B must be deferred until the step-over finishes. - The test runs with both "set detach-on-fork" on and off. When off, it exercises the case of GDB detaching the fork child explicitly. When on, it exercises the case of gdb resuming the child explicitly. In the "off" case, gdb seems to exponentially become slower as new inferiors are created. This is _very_ noticeable as with only 100 inferiors gdb is crawling already, which makes the test take quite a bit to run. For that reason, I've disabled the "off" variant for now. gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * target/waitstatus.h (enum target_stop_reason) <TARGET_STOPPED_BY_SINGLE_STEP>: New value. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the fork child's suspend count if stopping and suspending threads. (check_stopped_by_breakpoint): If stopped by trace, set the LWP's stop reason to TARGET_STOPPED_BY_SINGLE_STEP. (linux_detach): Complete an ongoing step-over. (lwp_suspended_inc, lwp_suspended_decr): New functions. Use throughout. (resume_stopped_resumed_lwps): Don't resume a suspended thread. (linux_wait_1): If passing a signal to the inferior after finishing a step-over, unsuspend and re-resume all lwps. If we see a single-step event but the thread should be continuing, don't pass the trap to gdb. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use internal_error instead of gdb_assert. (enqueue_pending_signal): New function. (check_ptrace_stopped_lwp_gone): Add debug output. (start_step_over): Use internal_error instead of gdb_assert. (complete_ongoing_step_over): New function. (linux_resume_one_thread): Don't resume a suspended thread. (proceed_one_lwp): If the LWP is stepping over a breakpoint, reset it stepping. gdb/testsuite/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * gdb.threads/forking-threads-plus-breakpoint.exp: New file. * gdb.threads/forking-threads-plus-breakpoint.c: New file.
2015-08-06 11:30:18 +02:00
{
struct lwp_info *lwp;
int wstat;
int ret;
if (debug_threads)
debug_printf ("detach: step over in progress, finish it first\n");
/* Passing NULL_PTID as filter indicates we want all events to
be left pending. Eventually this returns when there are no
unwaited-for children left. */
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
ret = wait_for_event_filtered (minus_one_ptid, null_ptid, &wstat,
__WALL);
gdbserver: Fix non-stop / fork / step-over issues Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html This adds a test that has a multithreaded program have several threads continuously fork, while another thread continuously steps over a breakpoint. This exposes several intertwined issues, which this patch addresses: - When we're stopping and suspending threads, some thread may fork, and we missed setting its suspend count to 1, like we do when a new clone/thread is detected. When we next unsuspend threads, the fork child's suspend count goes below 0, which is bogus and fails an assertion. - If a step-over is cancelled because a signal arrives, but then gdb is not interested in the signal, we pass the signal straight back to the inferior. However, we miss that we need to re-increment the suspend counts of all other threads that had been paused for the step-over. As a result, other threads indefinitely end up stuck stopped. - If a detach request comes in just while gdbserver is handling a step-over (in the test at hand, this is GDB detaching the fork child), gdbserver internal errors in stabilize_thread's helpers, which assert that all thread's suspend counts are 0 (otherwise we wouldn't be able to move threads out of the jump pads). The suspend counts aren't 0 while a step-over is in progress, because all threads but the one stepping past the breakpoint must remain paused until the step-over finishes and the breakpoint can be reinserted. - Occasionally, we see "BAD - reinserting but not stepping." being output (from within linux_resume_one_lwp_throw). That was because GDB pokes memory while gdbserver is busy with a step-over, and that suspends threads, and then re-resumes them with proceed_one_lwp, which missed another reason to tell linux_resume_one_lwp that the thread should be set back to stepping. - In a couple places, we were resuming threads that are meant to be suspended. E.g., when a vCont;c/s request for thread B comes in just while gdbserver is stepping thread A past a breakpoint. The resume for thread B must be deferred until the step-over finishes. - The test runs with both "set detach-on-fork" on and off. When off, it exercises the case of GDB detaching the fork child explicitly. When on, it exercises the case of gdb resuming the child explicitly. In the "off" case, gdb seems to exponentially become slower as new inferiors are created. This is _very_ noticeable as with only 100 inferiors gdb is crawling already, which makes the test take quite a bit to run. For that reason, I've disabled the "off" variant for now. gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * target/waitstatus.h (enum target_stop_reason) <TARGET_STOPPED_BY_SINGLE_STEP>: New value. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the fork child's suspend count if stopping and suspending threads. (check_stopped_by_breakpoint): If stopped by trace, set the LWP's stop reason to TARGET_STOPPED_BY_SINGLE_STEP. (linux_detach): Complete an ongoing step-over. (lwp_suspended_inc, lwp_suspended_decr): New functions. Use throughout. (resume_stopped_resumed_lwps): Don't resume a suspended thread. (linux_wait_1): If passing a signal to the inferior after finishing a step-over, unsuspend and re-resume all lwps. If we see a single-step event but the thread should be continuing, don't pass the trap to gdb. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use internal_error instead of gdb_assert. (enqueue_pending_signal): New function. (check_ptrace_stopped_lwp_gone): Add debug output. (start_step_over): Use internal_error instead of gdb_assert. (complete_ongoing_step_over): New function. (linux_resume_one_thread): Don't resume a suspended thread. (proceed_one_lwp): If the LWP is stepping over a breakpoint, reset it stepping. gdb/testsuite/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * gdb.threads/forking-threads-plus-breakpoint.exp: New file. * gdb.threads/forking-threads-plus-breakpoint.c: New file.
2015-08-06 11:30:18 +02:00
gdb_assert (ret == -1);
lwp = find_lwp_pid (step_over_bkpt);
if (lwp != NULL)
finish_step_over (lwp);
step_over_bkpt = null_ptid;
unsuspend_all_lwps (lwp);
}
}
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
void
linux_process_target::resume_one_thread (thread_info *thread,
bool leave_all_stopped)
{
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
struct lwp_info *lwp = get_thread_lwp (thread);
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
int leave_pending;
if (lwp->resume == NULL)
return;
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
if (lwp->resume->kind == resume_stop)
{
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
if (debug_threads)
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
debug_printf ("resume_stop request for LWP %ld\n", lwpid_of (thread));
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
if (!lwp->stopped)
{
if (debug_threads)
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
debug_printf ("stopping LWP %ld\n", lwpid_of (thread));
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
/* Stop the thread, and wait for the event asynchronously,
through the event loop. */
send_sigstop (lwp);
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
}
else
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("already stopped LWP %ld\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
lwpid_of (thread));
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
/* The LWP may have been stopped in an internal event that
was not meant to be notified back to GDB (e.g., gdbserver
breakpoint), so we should be reporting a stop event in
this case too. */
/* If the thread already has a pending SIGSTOP, this is a
no-op. Otherwise, something later will presumably resume
the thread and this will cause it to cancel any pending
operation, due to last_resume_kind == resume_stop. If
the thread already has a pending status to report, we
will still report it the next time we wait - see
status_pending_p_callback. */
/* If we already have a pending signal to report, then
there's no need to queue a SIGSTOP, as this means we're
midway through moving the LWP out of the jumppad, and we
will report the pending signal as soon as that is
finished. */
gdbserver/linux-low: use std::list to store pending signals Use std::list to store pending signals instead of a manually-managed linked list. This is a refactoring. In the existing code, pending signals are kept in a manually-created linked list with "prev" pointers. A new pending signal is thus inserted to the beginning of the list. When consuming, GDB goes until the end of the list, following the "prev" pointers, and processes the final item. With this patch, a new item is added to the end of the list and the item at the front of the list is consumed. In other words, the list elements used to be stored in reverse order; with this patch, they are stored in their order of arrival. This causes a change in the debug messages that print the pending signals. Otherwise, no behavioral change is expected. gdbserver/ChangeLog: 2020-06-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Use std::list to stop pending signal instead of manually-created linked list. * linux-low.h: Include <list>. (struct pending_signal): Move here from linux-low.cc. (struct lwp_info) <pending_signals> <pending_signals_to_report>: Update the type. * linux-low.cc (struct pending_signals): Remove. (linux_process_target::delete_lwp) (linux_process_target::add_lwp) (enqueue_one_deferred_signal) (dequeue_one_deferred_signal) (enqueue_pending_signal) (linux_process_target::resume_one_lwp_throw) (linux_process_target::thread_needs_step_over) (linux_process_target::resume_one_thread) (linux_process_target::proceed_one_lwp): Update the use of pending signal list.
2020-06-22 14:13:48 +02:00
if (lwp->pending_signals_to_report.empty ())
send_sigstop (lwp);
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
}
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
/* For stop requests, we're done. */
lwp->resume = NULL;
thread->last_status.kind = TARGET_WAITKIND_IGNORE;
return;
}
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
/* If this thread which is about to be resumed has a pending status,
gdbserver: Fix non-stop / fork / step-over issues Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html This adds a test that has a multithreaded program have several threads continuously fork, while another thread continuously steps over a breakpoint. This exposes several intertwined issues, which this patch addresses: - When we're stopping and suspending threads, some thread may fork, and we missed setting its suspend count to 1, like we do when a new clone/thread is detected. When we next unsuspend threads, the fork child's suspend count goes below 0, which is bogus and fails an assertion. - If a step-over is cancelled because a signal arrives, but then gdb is not interested in the signal, we pass the signal straight back to the inferior. However, we miss that we need to re-increment the suspend counts of all other threads that had been paused for the step-over. As a result, other threads indefinitely end up stuck stopped. - If a detach request comes in just while gdbserver is handling a step-over (in the test at hand, this is GDB detaching the fork child), gdbserver internal errors in stabilize_thread's helpers, which assert that all thread's suspend counts are 0 (otherwise we wouldn't be able to move threads out of the jump pads). The suspend counts aren't 0 while a step-over is in progress, because all threads but the one stepping past the breakpoint must remain paused until the step-over finishes and the breakpoint can be reinserted. - Occasionally, we see "BAD - reinserting but not stepping." being output (from within linux_resume_one_lwp_throw). That was because GDB pokes memory while gdbserver is busy with a step-over, and that suspends threads, and then re-resumes them with proceed_one_lwp, which missed another reason to tell linux_resume_one_lwp that the thread should be set back to stepping. - In a couple places, we were resuming threads that are meant to be suspended. E.g., when a vCont;c/s request for thread B comes in just while gdbserver is stepping thread A past a breakpoint. The resume for thread B must be deferred until the step-over finishes. - The test runs with both "set detach-on-fork" on and off. When off, it exercises the case of GDB detaching the fork child explicitly. When on, it exercises the case of gdb resuming the child explicitly. In the "off" case, gdb seems to exponentially become slower as new inferiors are created. This is _very_ noticeable as with only 100 inferiors gdb is crawling already, which makes the test take quite a bit to run. For that reason, I've disabled the "off" variant for now. gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * target/waitstatus.h (enum target_stop_reason) <TARGET_STOPPED_BY_SINGLE_STEP>: New value. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the fork child's suspend count if stopping and suspending threads. (check_stopped_by_breakpoint): If stopped by trace, set the LWP's stop reason to TARGET_STOPPED_BY_SINGLE_STEP. (linux_detach): Complete an ongoing step-over. (lwp_suspended_inc, lwp_suspended_decr): New functions. Use throughout. (resume_stopped_resumed_lwps): Don't resume a suspended thread. (linux_wait_1): If passing a signal to the inferior after finishing a step-over, unsuspend and re-resume all lwps. If we see a single-step event but the thread should be continuing, don't pass the trap to gdb. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use internal_error instead of gdb_assert. (enqueue_pending_signal): New function. (check_ptrace_stopped_lwp_gone): Add debug output. (start_step_over): Use internal_error instead of gdb_assert. (complete_ongoing_step_over): New function. (linux_resume_one_thread): Don't resume a suspended thread. (proceed_one_lwp): If the LWP is stepping over a breakpoint, reset it stepping. gdb/testsuite/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * gdb.threads/forking-threads-plus-breakpoint.exp: New file. * gdb.threads/forking-threads-plus-breakpoint.c: New file.
2015-08-06 11:30:18 +02:00
then don't resume it - we can just report the pending status.
Likewise if it is suspended, because e.g., another thread is
stepping past a breakpoint. Make sure to queue any signals that
would otherwise be sent. In all-stop mode, we do this decision
based on if *any* thread has a pending status. If there's a
thread that needs the step-over-breakpoint dance, then don't
resume any other thread but that particular one. */
leave_pending = (lwp->suspended
|| lwp->status_pending_p
|| leave_all_stopped);
/* If we have a new signal, enqueue the signal. */
if (lwp->resume->sig != 0)
{
siginfo_t info, *info_p;
/* If this is the same signal we were previously stopped by,
make sure to queue its siginfo. */
if (WIFSTOPPED (lwp->last_status)
&& WSTOPSIG (lwp->last_status) == lwp->resume->sig
&& ptrace (PTRACE_GETSIGINFO, lwpid_of (thread),
(PTRACE_TYPE_ARG3) 0, &info) == 0)
info_p = &info;
else
info_p = NULL;
enqueue_pending_signal (lwp, lwp->resume->sig, info_p);
}
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
if (!leave_pending)
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
{
if (debug_threads)
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
debug_printf ("resuming LWP %ld\n", lwpid_of (thread));
gdbserver: use std::list for all_threads Remove the usage of inferior_list for the all_threads list in gdbserver. The entry field in thread_info is removed, and replaced by a simple ptid field. I added some functions to iterate (for_each_thread) and find threads (find_thread). However, changing all the users of find_inferior & co to use these new functions would have made the patch way too big. So I opted instead to make find_inferior & co some shims, so that the existing code only needs to be updated minimally. We can then update the existing code to use the new functions incrementally (I've started to do the work, but I'll post it afterwards, see [1] if you want a peek). This patch has been built-tested on all relevant platforms, except lynx. I also regtested using the native-gdbserver and native-extended-gdbserver boards on x86. [1] https://github.com/simark/binutils-gdb/commits/kill-inferior-list-entry gdb/gdbserver/ChangeLog: * inferiors.h: (struct inferior_list): Remove. (struct inferior_list_entry); Remove. (add_inferior_to_list, clear_inferior_list, one_inferior_p, A_I_NEXT, ALL_INFERIORS_TYPE, ALL_INFERIORS, remove_inferior, get_first_inferior): Remove. (for_each_inferior, for_each_inferior_with_data, find_inferior, find_inferior_id, find_inferior_in_random): Change signature. * inferiors.c (all_threads): Change type to std::list<thread_info *>. (get_thread): Remove macro. (find_inferior, find_inferior_id): Change signature, implement using find_thread. (find_inferior_in_random): Change signature, implement using find_thread_in_random. (for_each_inferior, for_each_inferior_with_data): Change signature, implement using for_each_thread. (add_inferior_to_list, remove_inferior): Remove. (add_thread, get_first_thread, thread_of_pid, find_any_thread_of_pid, free_one_thread, remove_thread): Update. (get_first_inferior, one_inferior_p, clear_inferior_list): Remove. (clear_inferiors, get_thread_process): Update. * gdbthread.h: Include <list>. (struct thread_info) <entry>: Remove field. <id>: New field. (all_threads): Change type to std::list<thread_info *>. (get_first_inferior): Add doc. (find_thread, for_each_thread, find_thread_in_random): New functions. (current_ptid, pid_of, ptid_of, lwpid_of): Update. * linux-arm-low.c (update_registers_callback): Update. * linux-low.c (second_thread_of_pid_p): Update. (kill_one_lwp_callback, linux_detach_lwp_callback, delete_lwp_callback, status_pending_p_callback, same_lwp, find_lwp_pid, num_lwps, iterate_over_lwps_filter, iterate_over_lwps, not_stopped_callback, resume_stopped_resumed_lwps, count_events_callback, select_singlestep_lwp_callback, select_event_lwp_callback, unsuspend_one_lwp, linux_wait_1, send_sigstop_callback, suspend_and_send_sigstop_callback, wait_for_sigstop, stuck_in_jump_pad_callback, move_out_of_jump_pad_callback, lwp_running, linux_set_resume_request, resume_status_pending_p, need_step_over_p, start_step_over, linux_resume_one_thread, proceed_one_lwp, unsuspend_and_proceed_one_lwp, reset_lwp_ptrace_options_callback): Update. * linux-mips-low.c (update_watch_registers_callback): Update. * regcache.c (regcache_invalidate_one, regcache_invalidate): Update. (free_register_cache_thread_one): Remove. (regcache_release): Update. * server.c (handle_btrace_enable_bts, handle_btrace_enable_pt, handle_qxfer_threads_worker): Update. (handle_query): Update, use list iterator. (visit_actioned_threads, handle_pending_status, queue_stop_reply_callback, gdb_wants_all_threads_stopped, clear_pending_status_callback, set_pending_status_callback, find_status_pending_thread_callback, handle_status, process_serial_event): Update. * target.c (thread_search_callback): Update. * thread-db.c (thread_db_get_tls_address): Update. * tracepoint.c (tracepoint_finished_step, tracepoint_was_hit): Update. * win32-i386-low.c (update_debug_registers_callback): Update. * win32-low.c (delete_thread_info, child_delete_thread, continue_one_thread, suspend_one_thread, get_child_debug_event): Adjust.
2017-10-14 15:11:12 +02:00
proceed_one_lwp (thread, NULL);
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
}
else
{
if (debug_threads)
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
debug_printf ("leaving LWP %ld stopped\n", lwpid_of (thread));
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
}
thread->last_status.kind = TARGET_WAITKIND_IGNORE;
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
lwp->resume = NULL;
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
}
void
linux_process_target::resume (thread_resume *resume_info, size_t n)
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
{
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
struct thread_info *need_step_over = NULL;
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
if (debug_threads)
{
debug_enter ();
debug_printf ("linux_resume:\n");
}
for_each_thread ([&] (thread_info *thread)
{
linux_set_resume_request (thread, resume_info, n);
});
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
/* If there is a thread which would otherwise be resumed, which has
a pending status, then don't resume any threads - we can just
report the pending status. Make sure to queue any signals that
would otherwise be sent. In non-stop mode, we'll apply this
logic to each thread individually. We consume all pending events
before considering to start a step-over (in all-stop). */
bool any_pending = false;
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
if (!non_stop)
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
any_pending = find_thread ([this] (thread_info *thread)
{
return resume_status_pending (thread);
}) != nullptr;
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
/* If there is a thread which would otherwise be resumed, which is
stopped at a breakpoint that needs stepping over, then don't
resume any threads - have it step over the breakpoint with all
other threads stopped, then resume all threads again. Make sure
to queue any signals that would otherwise be delivered or
queued. */
gdbserver/linux-low: turn 'get_pc' and 'set_pc' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_pc' and 'set_pc' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. * linux-low.cc (supports_breakpoints): Turn into... (linux_process_target::low_supports_breakpoints): ...this. (linux_process_target::low_get_pc): Define. (linux_process_target::low_set_pc): Define. Update the callers below. (linux_process_target::get_pc) (linux_process_target::save_stop_reason) (linux_process_target::maybe_move_out_of_jump_pad) (linux_process_target::wait_1) (linux_process_target::resume_one_lwp_throw) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (linux_process_target::read_pc) (linux_process_target::write_pc) * linux-x86-low.cc (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (x86_target::low_supports_breakpoints): Define. (x86_get_pc): Turn into... (x86_target::low_get_pc): ...this. (x86_set_pc): Turn into... (x86_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (arm_target::low_supports_breakpoints) (arm_target::low_get_pc) (arm_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (bfin_target::low_supports_breakpoints) (bfin_target::low_get_pc) (bfin_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (cris_target::low_supports_breakpoints) (cris_target::low_get_pc) (cris_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (crisv32_target::low_supports_breakpoints) (crisv32_target::low_get_pc) (crisv32_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m32r_target::low_supports_breakpoints) (m32r_target::low_get_pc) (m32r_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m68k_target::low_supports_breakpoints) (m68k_target::low_get_pc) (m68k_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (nios2_target::low_supports_breakpoints) (nios2_target::low_get_pc) (nios2_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (sh_target::low_supports_breakpoints) (sh_target::low_get_pc) (sh_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (xtensa_target::low_supports_breakpoints) (xtensa_target::low_get_pc) (xtensa_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_supports_breakpoints> <low_get_pc>: Declare. (sparc_target::low_supports_breakpoints) (sparc_target::low_get_pc): Define. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tile_target::low_supports_breakpoints) (tile_target::low_get_pc) (tile_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (aarch64_target::low_supports_breakpoints): Define. (aarch64_get_pc): Turn into... (aarch64_target::low_get_pc): ...this. (aarch64_set_pc): Turn into... (aarch64_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (mips_target::low_supports_breakpoints): Define. (mips_get_pc): Turn into... (mips_target::low_get_pc): ...this. (mips_set_pc): Turn into... (mips_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (ppc_target::low_supports_breakpoints): Define. (ppc_get_pc): Turn into... (ppc_target::low_get_pc): ...this. (ppc_set_pc): Turn into... (ppc_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (riscv_target::low_supports_breakpoints): Define. (riscv_get_pc): Turn into... (riscv_target::low_get_pc): ...this. (riscv_set_pc): Turn into... (riscv_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (s390_target::low_supports_breakpoints): Define. (s390_get_pc): Turn into... (s390_target::low_get_pc): ...this. (s390_set_pc): Turn into... (s390_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tic6x_target::low_supports_breakpoints): Define. (tic6x_get_pc): Turn into... (tic6x_target::low_get_pc): ...this. (tic6x_set_pc): Turn into... (tic6x_target::low_set_pc): ...this. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
if (!any_pending && low_supports_breakpoints ())
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
need_step_over = find_thread ([this] (thread_info *thread)
{
return thread_needs_step_over (thread);
});
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
bool leave_all_stopped = (need_step_over != NULL || any_pending);
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
if (debug_threads)
{
if (need_step_over != NULL)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Not resuming all, need step over\n");
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
else if (any_pending)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Not resuming, all-stop and found "
"an LWP with pending status\n");
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
else
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Resuming, no pending status or step over needed\n");
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
}
/* Even if we're leaving threads stopped, queue all signals we'd
otherwise deliver. */
for_each_thread ([&] (thread_info *thread)
{
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
resume_one_thread (thread, leave_all_stopped);
});
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
if (need_step_over)
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
start_step_over (get_thread_lwp (need_step_over));
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
if (debug_threads)
{
debug_printf ("linux_resume done\n");
debug_exit ();
}
/* We may have events that were pending that can/should be sent to
the client now. Trigger a linux_wait call. */
if (target_is_async_p ())
async_file_mark ();
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
}
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
void
linux_process_target::proceed_one_lwp (thread_info *thread, lwp_info *except)
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
{
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
struct lwp_info *lwp = get_thread_lwp (thread);
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
int step;
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
if (lwp == except)
return;
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
if (debug_threads)
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
debug_printf ("proceed_one_lwp: lwp %ld\n", lwpid_of (thread));
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
if (!lwp->stopped)
{
if (debug_threads)
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
debug_printf (" LWP %ld already running\n", lwpid_of (thread));
return;
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
}
if (thread->last_resume_kind == resume_stop
&& thread->last_status.kind != TARGET_WAITKIND_IGNORE)
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf (" client wants LWP to remain %ld stopped\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
lwpid_of (thread));
return;
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
}
if (lwp->status_pending_p)
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf (" LWP %ld has pending status, leaving stopped\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
lwpid_of (thread));
return;
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
}
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
gdb_assert (lwp->suspended >= 0);
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
if (lwp->suspended)
{
if (debug_threads)
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
debug_printf (" LWP %ld is suspended\n", lwpid_of (thread));
return;
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
}
if (thread->last_resume_kind == resume_stop
gdbserver/linux-low: use std::list to store pending signals Use std::list to store pending signals instead of a manually-managed linked list. This is a refactoring. In the existing code, pending signals are kept in a manually-created linked list with "prev" pointers. A new pending signal is thus inserted to the beginning of the list. When consuming, GDB goes until the end of the list, following the "prev" pointers, and processes the final item. With this patch, a new item is added to the end of the list and the item at the front of the list is consumed. In other words, the list elements used to be stored in reverse order; with this patch, they are stored in their order of arrival. This causes a change in the debug messages that print the pending signals. Otherwise, no behavioral change is expected. gdbserver/ChangeLog: 2020-06-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Use std::list to stop pending signal instead of manually-created linked list. * linux-low.h: Include <list>. (struct pending_signal): Move here from linux-low.cc. (struct lwp_info) <pending_signals> <pending_signals_to_report>: Update the type. * linux-low.cc (struct pending_signals): Remove. (linux_process_target::delete_lwp) (linux_process_target::add_lwp) (enqueue_one_deferred_signal) (dequeue_one_deferred_signal) (enqueue_pending_signal) (linux_process_target::resume_one_lwp_throw) (linux_process_target::thread_needs_step_over) (linux_process_target::resume_one_thread) (linux_process_target::proceed_one_lwp): Update the use of pending signal list.
2020-06-22 14:13:48 +02:00
&& lwp->pending_signals_to_report.empty ()
&& (lwp->collecting_fast_tracepoint
== fast_tpoint_collect_result::not_collecting))
{
/* We haven't reported this LWP as stopped yet (otherwise, the
last_status.kind check above would catch it, and we wouldn't
reach here. This LWP may have been momentarily paused by a
stop_all_lwps call while handling for example, another LWP's
step-over. In that case, the pending expected SIGSTOP signal
that was queued at vCont;t handling time will have already
been consumed by wait_for_sigstop, and so we need to requeue
another one here. Note that if the LWP already has a SIGSTOP
pending, this is a no-op. */
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Client wants LWP %ld to stop. "
"Making sure it has a SIGSTOP pending\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
lwpid_of (thread));
send_sigstop (lwp);
}
gdbserver: Fix non-stop / fork / step-over issues Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html This adds a test that has a multithreaded program have several threads continuously fork, while another thread continuously steps over a breakpoint. This exposes several intertwined issues, which this patch addresses: - When we're stopping and suspending threads, some thread may fork, and we missed setting its suspend count to 1, like we do when a new clone/thread is detected. When we next unsuspend threads, the fork child's suspend count goes below 0, which is bogus and fails an assertion. - If a step-over is cancelled because a signal arrives, but then gdb is not interested in the signal, we pass the signal straight back to the inferior. However, we miss that we need to re-increment the suspend counts of all other threads that had been paused for the step-over. As a result, other threads indefinitely end up stuck stopped. - If a detach request comes in just while gdbserver is handling a step-over (in the test at hand, this is GDB detaching the fork child), gdbserver internal errors in stabilize_thread's helpers, which assert that all thread's suspend counts are 0 (otherwise we wouldn't be able to move threads out of the jump pads). The suspend counts aren't 0 while a step-over is in progress, because all threads but the one stepping past the breakpoint must remain paused until the step-over finishes and the breakpoint can be reinserted. - Occasionally, we see "BAD - reinserting but not stepping." being output (from within linux_resume_one_lwp_throw). That was because GDB pokes memory while gdbserver is busy with a step-over, and that suspends threads, and then re-resumes them with proceed_one_lwp, which missed another reason to tell linux_resume_one_lwp that the thread should be set back to stepping. - In a couple places, we were resuming threads that are meant to be suspended. E.g., when a vCont;c/s request for thread B comes in just while gdbserver is stepping thread A past a breakpoint. The resume for thread B must be deferred until the step-over finishes. - The test runs with both "set detach-on-fork" on and off. When off, it exercises the case of GDB detaching the fork child explicitly. When on, it exercises the case of gdb resuming the child explicitly. In the "off" case, gdb seems to exponentially become slower as new inferiors are created. This is _very_ noticeable as with only 100 inferiors gdb is crawling already, which makes the test take quite a bit to run. For that reason, I've disabled the "off" variant for now. gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * target/waitstatus.h (enum target_stop_reason) <TARGET_STOPPED_BY_SINGLE_STEP>: New value. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the fork child's suspend count if stopping and suspending threads. (check_stopped_by_breakpoint): If stopped by trace, set the LWP's stop reason to TARGET_STOPPED_BY_SINGLE_STEP. (linux_detach): Complete an ongoing step-over. (lwp_suspended_inc, lwp_suspended_decr): New functions. Use throughout. (resume_stopped_resumed_lwps): Don't resume a suspended thread. (linux_wait_1): If passing a signal to the inferior after finishing a step-over, unsuspend and re-resume all lwps. If we see a single-step event but the thread should be continuing, don't pass the trap to gdb. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use internal_error instead of gdb_assert. (enqueue_pending_signal): New function. (check_ptrace_stopped_lwp_gone): Add debug output. (start_step_over): Use internal_error instead of gdb_assert. (complete_ongoing_step_over): New function. (linux_resume_one_thread): Don't resume a suspended thread. (proceed_one_lwp): If the LWP is stepping over a breakpoint, reset it stepping. gdb/testsuite/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * gdb.threads/forking-threads-plus-breakpoint.exp: New file. * gdb.threads/forking-threads-plus-breakpoint.c: New file.
2015-08-06 11:30:18 +02:00
if (thread->last_resume_kind == resume_step)
{
if (debug_threads)
debug_printf (" stepping LWP %ld, client wants it stepping\n",
lwpid_of (thread));
/* If resume_step is requested by GDB, install single-step
breakpoints when the thread is about to be actually resumed if
the single-step breakpoints weren't removed. */
gdbserver/linux-low: turn 'supports_software_single_step' and 'get_next_pcs' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Remove the 'supports_software_single_step' linux target op and let the concrete linux target define it by overriding the op in process_stratum_target. Turn the 'get_next_pcs' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <supports_software_single_step>: Remove. <low_get_next_pcs>: Declare. * linux-low.cc (can_software_single_step): Remove. (linux_process_target::low_get_next_pcs): Define. (linux_process_target::supports_software_single_step): Remove. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::wait_1) (linux_process_target::install_software_single_step_breakpoints) (linux_process_target::single_step) (linux_process_target::thread_needs_step_over) (linux_process_target::proceed_one_lwp) (linux_process_target::supports_range_stepping) * linux-x86-low.cc (the_low_target): Remove the op field. * linux-aarch64-low.cc (the_low_target): Ditto. * linux-bfin-low.cc (the_low_target): Ditto. * linux-cris-low.cc (the_low_target): Ditto. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-mips-low.cc (the_low_target): Ditto. * linux-nios2-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-riscv-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-sparc-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto. * linux-arm-low.cc (class arm_target) <low_get_next_pcs> <supports_software_single_step>: Declare. (arm_target::supports_software_single_step): Define. (arm_gdbserver_get_next_pcs): Turn into... (arm_target::low_get_next_pcs): ...this. (the_low_target): Remove the op field.
2020-04-02 15:11:26 +02:00
if (supports_software_single_step ()
&& !has_single_step_breakpoints (thread))
install_software_single_step_breakpoints (lwp);
step = maybe_hw_step (thread);
gdbserver: Fix non-stop / fork / step-over issues Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html This adds a test that has a multithreaded program have several threads continuously fork, while another thread continuously steps over a breakpoint. This exposes several intertwined issues, which this patch addresses: - When we're stopping and suspending threads, some thread may fork, and we missed setting its suspend count to 1, like we do when a new clone/thread is detected. When we next unsuspend threads, the fork child's suspend count goes below 0, which is bogus and fails an assertion. - If a step-over is cancelled because a signal arrives, but then gdb is not interested in the signal, we pass the signal straight back to the inferior. However, we miss that we need to re-increment the suspend counts of all other threads that had been paused for the step-over. As a result, other threads indefinitely end up stuck stopped. - If a detach request comes in just while gdbserver is handling a step-over (in the test at hand, this is GDB detaching the fork child), gdbserver internal errors in stabilize_thread's helpers, which assert that all thread's suspend counts are 0 (otherwise we wouldn't be able to move threads out of the jump pads). The suspend counts aren't 0 while a step-over is in progress, because all threads but the one stepping past the breakpoint must remain paused until the step-over finishes and the breakpoint can be reinserted. - Occasionally, we see "BAD - reinserting but not stepping." being output (from within linux_resume_one_lwp_throw). That was because GDB pokes memory while gdbserver is busy with a step-over, and that suspends threads, and then re-resumes them with proceed_one_lwp, which missed another reason to tell linux_resume_one_lwp that the thread should be set back to stepping. - In a couple places, we were resuming threads that are meant to be suspended. E.g., when a vCont;c/s request for thread B comes in just while gdbserver is stepping thread A past a breakpoint. The resume for thread B must be deferred until the step-over finishes. - The test runs with both "set detach-on-fork" on and off. When off, it exercises the case of GDB detaching the fork child explicitly. When on, it exercises the case of gdb resuming the child explicitly. In the "off" case, gdb seems to exponentially become slower as new inferiors are created. This is _very_ noticeable as with only 100 inferiors gdb is crawling already, which makes the test take quite a bit to run. For that reason, I've disabled the "off" variant for now. gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * target/waitstatus.h (enum target_stop_reason) <TARGET_STOPPED_BY_SINGLE_STEP>: New value. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the fork child's suspend count if stopping and suspending threads. (check_stopped_by_breakpoint): If stopped by trace, set the LWP's stop reason to TARGET_STOPPED_BY_SINGLE_STEP. (linux_detach): Complete an ongoing step-over. (lwp_suspended_inc, lwp_suspended_decr): New functions. Use throughout. (resume_stopped_resumed_lwps): Don't resume a suspended thread. (linux_wait_1): If passing a signal to the inferior after finishing a step-over, unsuspend and re-resume all lwps. If we see a single-step event but the thread should be continuing, don't pass the trap to gdb. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use internal_error instead of gdb_assert. (enqueue_pending_signal): New function. (check_ptrace_stopped_lwp_gone): Add debug output. (start_step_over): Use internal_error instead of gdb_assert. (complete_ongoing_step_over): New function. (linux_resume_one_thread): Don't resume a suspended thread. (proceed_one_lwp): If the LWP is stepping over a breakpoint, reset it stepping. gdb/testsuite/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * gdb.threads/forking-threads-plus-breakpoint.exp: New file. * gdb.threads/forking-threads-plus-breakpoint.c: New file.
2015-08-06 11:30:18 +02:00
}
else if (lwp->bp_reinsert != 0)
{
if (debug_threads)
debug_printf (" stepping LWP %ld, reinsert set\n",
lwpid_of (thread));
Switch to current thread in finish_step_over This patch adds some sanity check that reinsert breakpoints must be there when doing step-over on software single step target. The check triggers an assert when running forking-threads-plus-breakpoint.exp on arm-linux target, gdb/gdbserver/linux-low.c:4714: A problem internal to GDBserver has been detected.^M int finish_step_over(lwp_info*): Assertion `has_reinsert_breakpoints ()' failed. the error happens when GDBserver has already resumed a thread of process A for step-over (and wait for it hitting reinsert breakpoint), but receives detach request for process B from GDB, which is shown in the backtrace below, (gdb) bt #2 0x000228aa in finish_step_over (lwp=0x12bbd98) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4703 #3 0x00025a50 in finish_step_over (lwp=0x12bbd98) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4749 #4 complete_ongoing_step_over () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4760 #5 linux_detach (pid=25228) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:1503 #6 0x00012bae in process_serial_event () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3974 #7 handle_serial_event (err=<optimized out>, client_data=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:4347 #8 0x00016d68 in handle_file_event (event_file_desc=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:429 #9 0x000173ea in process_event () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:184 #10 start_event_loop () at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/event-loop.c:547 #11 0x0000aa2c in captured_main (argv=<optimized out>, argc=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3719 #12 main (argc=<optimized out>, argv=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/server.c:3804 the sanity check tries to find the reinsert breakpoint from process B, but nothing is found. It is wrong, we need to search in process A, since we started step-over of a thread of process A. (gdb) p lwp->thread->entry.id $3 = {pid = 25120, lwp = 25131, tid = 0} (gdb) p current_thread->entry.id $4 = {pid = 25228, lwp = 25228, tid = 0} This patch switched current_thread to the thread we are doing step-over in finish_step_over. gdb/gdbserver: 2016-06-17 Yao Qi <yao.qi@linaro.org> * linux-low.c (maybe_hw_step): New function. (linux_resume_one_lwp_throw): Call maybe_hw_step. (finish_step_over): Switch current_thread to lwp temporarily, and assert has_reinsert_breakpoints returns true. (proceed_one_lwp): Call maybe_hw_step. * mem-break.c (has_reinsert_breakpoints): New function. * mem-break.h (has_reinsert_breakpoints): Declare.
2016-06-17 11:25:12 +02:00
step = maybe_hw_step (thread);
gdbserver: Fix non-stop / fork / step-over issues Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html This adds a test that has a multithreaded program have several threads continuously fork, while another thread continuously steps over a breakpoint. This exposes several intertwined issues, which this patch addresses: - When we're stopping and suspending threads, some thread may fork, and we missed setting its suspend count to 1, like we do when a new clone/thread is detected. When we next unsuspend threads, the fork child's suspend count goes below 0, which is bogus and fails an assertion. - If a step-over is cancelled because a signal arrives, but then gdb is not interested in the signal, we pass the signal straight back to the inferior. However, we miss that we need to re-increment the suspend counts of all other threads that had been paused for the step-over. As a result, other threads indefinitely end up stuck stopped. - If a detach request comes in just while gdbserver is handling a step-over (in the test at hand, this is GDB detaching the fork child), gdbserver internal errors in stabilize_thread's helpers, which assert that all thread's suspend counts are 0 (otherwise we wouldn't be able to move threads out of the jump pads). The suspend counts aren't 0 while a step-over is in progress, because all threads but the one stepping past the breakpoint must remain paused until the step-over finishes and the breakpoint can be reinserted. - Occasionally, we see "BAD - reinserting but not stepping." being output (from within linux_resume_one_lwp_throw). That was because GDB pokes memory while gdbserver is busy with a step-over, and that suspends threads, and then re-resumes them with proceed_one_lwp, which missed another reason to tell linux_resume_one_lwp that the thread should be set back to stepping. - In a couple places, we were resuming threads that are meant to be suspended. E.g., when a vCont;c/s request for thread B comes in just while gdbserver is stepping thread A past a breakpoint. The resume for thread B must be deferred until the step-over finishes. - The test runs with both "set detach-on-fork" on and off. When off, it exercises the case of GDB detaching the fork child explicitly. When on, it exercises the case of gdb resuming the child explicitly. In the "off" case, gdb seems to exponentially become slower as new inferiors are created. This is _very_ noticeable as with only 100 inferiors gdb is crawling already, which makes the test take quite a bit to run. For that reason, I've disabled the "off" variant for now. gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * target/waitstatus.h (enum target_stop_reason) <TARGET_STOPPED_BY_SINGLE_STEP>: New value. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the fork child's suspend count if stopping and suspending threads. (check_stopped_by_breakpoint): If stopped by trace, set the LWP's stop reason to TARGET_STOPPED_BY_SINGLE_STEP. (linux_detach): Complete an ongoing step-over. (lwp_suspended_inc, lwp_suspended_decr): New functions. Use throughout. (resume_stopped_resumed_lwps): Don't resume a suspended thread. (linux_wait_1): If passing a signal to the inferior after finishing a step-over, unsuspend and re-resume all lwps. If we see a single-step event but the thread should be continuing, don't pass the trap to gdb. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use internal_error instead of gdb_assert. (enqueue_pending_signal): New function. (check_ptrace_stopped_lwp_gone): Add debug output. (start_step_over): Use internal_error instead of gdb_assert. (complete_ongoing_step_over): New function. (linux_resume_one_thread): Don't resume a suspended thread. (proceed_one_lwp): If the LWP is stepping over a breakpoint, reset it stepping. gdb/testsuite/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * gdb.threads/forking-threads-plus-breakpoint.exp: New file. * gdb.threads/forking-threads-plus-breakpoint.c: New file.
2015-08-06 11:30:18 +02:00
}
else
step = 0;
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
resume_one_lwp (lwp, step, 0, NULL);
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
}
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
void
linux_process_target::unsuspend_and_proceed_one_lwp (thread_info *thread,
lwp_info *except)
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
{
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
struct lwp_info *lwp = get_thread_lwp (thread);
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
if (lwp == except)
return;
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
gdbserver: Fix non-stop / fork / step-over issues Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html This adds a test that has a multithreaded program have several threads continuously fork, while another thread continuously steps over a breakpoint. This exposes several intertwined issues, which this patch addresses: - When we're stopping and suspending threads, some thread may fork, and we missed setting its suspend count to 1, like we do when a new clone/thread is detected. When we next unsuspend threads, the fork child's suspend count goes below 0, which is bogus and fails an assertion. - If a step-over is cancelled because a signal arrives, but then gdb is not interested in the signal, we pass the signal straight back to the inferior. However, we miss that we need to re-increment the suspend counts of all other threads that had been paused for the step-over. As a result, other threads indefinitely end up stuck stopped. - If a detach request comes in just while gdbserver is handling a step-over (in the test at hand, this is GDB detaching the fork child), gdbserver internal errors in stabilize_thread's helpers, which assert that all thread's suspend counts are 0 (otherwise we wouldn't be able to move threads out of the jump pads). The suspend counts aren't 0 while a step-over is in progress, because all threads but the one stepping past the breakpoint must remain paused until the step-over finishes and the breakpoint can be reinserted. - Occasionally, we see "BAD - reinserting but not stepping." being output (from within linux_resume_one_lwp_throw). That was because GDB pokes memory while gdbserver is busy with a step-over, and that suspends threads, and then re-resumes them with proceed_one_lwp, which missed another reason to tell linux_resume_one_lwp that the thread should be set back to stepping. - In a couple places, we were resuming threads that are meant to be suspended. E.g., when a vCont;c/s request for thread B comes in just while gdbserver is stepping thread A past a breakpoint. The resume for thread B must be deferred until the step-over finishes. - The test runs with both "set detach-on-fork" on and off. When off, it exercises the case of GDB detaching the fork child explicitly. When on, it exercises the case of gdb resuming the child explicitly. In the "off" case, gdb seems to exponentially become slower as new inferiors are created. This is _very_ noticeable as with only 100 inferiors gdb is crawling already, which makes the test take quite a bit to run. For that reason, I've disabled the "off" variant for now. gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * target/waitstatus.h (enum target_stop_reason) <TARGET_STOPPED_BY_SINGLE_STEP>: New value. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Set the fork child's suspend count if stopping and suspending threads. (check_stopped_by_breakpoint): If stopped by trace, set the LWP's stop reason to TARGET_STOPPED_BY_SINGLE_STEP. (linux_detach): Complete an ongoing step-over. (lwp_suspended_inc, lwp_suspended_decr): New functions. Use throughout. (resume_stopped_resumed_lwps): Don't resume a suspended thread. (linux_wait_1): If passing a signal to the inferior after finishing a step-over, unsuspend and re-resume all lwps. If we see a single-step event but the thread should be continuing, don't pass the trap to gdb. (stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use internal_error instead of gdb_assert. (enqueue_pending_signal): New function. (check_ptrace_stopped_lwp_gone): Add debug output. (start_step_over): Use internal_error instead of gdb_assert. (complete_ongoing_step_over): New function. (linux_resume_one_thread): Don't resume a suspended thread. (proceed_one_lwp): If the LWP is stepping over a breakpoint, reset it stepping. gdb/testsuite/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * gdb.threads/forking-threads-plus-breakpoint.exp: New file. * gdb.threads/forking-threads-plus-breakpoint.c: New file.
2015-08-06 11:30:18 +02:00
lwp_suspended_decr (lwp);
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
proceed_one_lwp (thread, except);
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
}
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
void
linux_process_target::proceed_all_lwps ()
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
{
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
struct thread_info *need_step_over;
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
/* If there is a thread which would otherwise be resumed, which is
stopped at a breakpoint that needs stepping over, then don't
resume any threads - have it step over the breakpoint with all
other threads stopped, then resume all threads again. */
gdbserver/linux-low: turn 'get_pc' and 'set_pc' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_pc' and 'set_pc' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. * linux-low.cc (supports_breakpoints): Turn into... (linux_process_target::low_supports_breakpoints): ...this. (linux_process_target::low_get_pc): Define. (linux_process_target::low_set_pc): Define. Update the callers below. (linux_process_target::get_pc) (linux_process_target::save_stop_reason) (linux_process_target::maybe_move_out_of_jump_pad) (linux_process_target::wait_1) (linux_process_target::resume_one_lwp_throw) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (linux_process_target::read_pc) (linux_process_target::write_pc) * linux-x86-low.cc (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (x86_target::low_supports_breakpoints): Define. (x86_get_pc): Turn into... (x86_target::low_get_pc): ...this. (x86_set_pc): Turn into... (x86_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (arm_target::low_supports_breakpoints) (arm_target::low_get_pc) (arm_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (bfin_target::low_supports_breakpoints) (bfin_target::low_get_pc) (bfin_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (cris_target::low_supports_breakpoints) (cris_target::low_get_pc) (cris_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (crisv32_target::low_supports_breakpoints) (crisv32_target::low_get_pc) (crisv32_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m32r_target::low_supports_breakpoints) (m32r_target::low_get_pc) (m32r_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m68k_target::low_supports_breakpoints) (m68k_target::low_get_pc) (m68k_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (nios2_target::low_supports_breakpoints) (nios2_target::low_get_pc) (nios2_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (sh_target::low_supports_breakpoints) (sh_target::low_get_pc) (sh_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (xtensa_target::low_supports_breakpoints) (xtensa_target::low_get_pc) (xtensa_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_supports_breakpoints> <low_get_pc>: Declare. (sparc_target::low_supports_breakpoints) (sparc_target::low_get_pc): Define. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tile_target::low_supports_breakpoints) (tile_target::low_get_pc) (tile_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (aarch64_target::low_supports_breakpoints): Define. (aarch64_get_pc): Turn into... (aarch64_target::low_get_pc): ...this. (aarch64_set_pc): Turn into... (aarch64_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (mips_target::low_supports_breakpoints): Define. (mips_get_pc): Turn into... (mips_target::low_get_pc): ...this. (mips_set_pc): Turn into... (mips_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (ppc_target::low_supports_breakpoints): Define. (ppc_get_pc): Turn into... (ppc_target::low_get_pc): ...this. (ppc_set_pc): Turn into... (ppc_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (riscv_target::low_supports_breakpoints): Define. (riscv_get_pc): Turn into... (riscv_target::low_get_pc): ...this. (riscv_set_pc): Turn into... (riscv_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (s390_target::low_supports_breakpoints): Define. (s390_get_pc): Turn into... (s390_target::low_get_pc): ...this. (s390_set_pc): Turn into... (s390_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tic6x_target::low_supports_breakpoints): Define. (tic6x_get_pc): Turn into... (tic6x_target::low_get_pc): ...this. (tic6x_set_pc): Turn into... (tic6x_target::low_set_pc): ...this. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
if (low_supports_breakpoints ())
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
{
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
need_step_over = find_thread ([this] (thread_info *thread)
{
return thread_needs_step_over (thread);
});
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
if (need_step_over != NULL)
{
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("proceed_all_lwps: found "
"thread %ld needing a step-over\n",
lwpid_of (need_step_over));
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
start_step_over (get_thread_lwp (need_step_over));
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
return;
}
}
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Proceeding, no step-over needed\n");
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
for_each_thread ([this] (thread_info *thread)
{
proceed_one_lwp (thread, NULL);
});
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
}
gdbserver/linux-low: turn some static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some static functions in linux-low.cc into private methods of linux_process_target. * linux-low.cc (handle_extended_wait): Turn into ... (linux_process_target::handle_extended_wait): ...this. Call 'mourn' on 'this' object instead of 'the_target'. (maybe_move_out_of_jump_pad): Turn into... (linux_process_target::maybe_move_out_of_jump_pad): ...this. (linux_low_filter_event): Turn into... (linux_process_target::filter_event): ...this. (linux_wait_for_event_filtered): Turn into... (linux_process_target::wait_for_event_filtered): ...this. (linux_wait_for_event): Turn into... (linux_process_target::wait_for_event): ...this. (linux_wait_1): Turn into... (linux_process_target::wait_1): ...this. (wait_for_sigstop): Turn into... (linux_process_target::wait_for_sigstop): ...this. (move_out_of_jump_pad_callback): Turn into... (linux_process_target::move_out_of_jump_pad): ...this. (stop_all_lwps): Turn into... (linux_process_target::stop_all_lwps): ...this. (start_step_over): Turn into... (linux_process_target::start_step_over): ...this. (complete_ongoing_step_over): Turn into... (linux_process_target::complete_ongoing_step_over): ...this. (proceed_all_lwps): Turn into... (linux_process_target::proceed_all_lwps): ...this. (unstop_all_lwps): Turn into... (linux_process_target::unstop_all_lwps): ...this. * linux-low.h (class linux_process_target) <handle_extended_wait> <maybe_move_out_of_jump_pad> filter_event> <wait_for_event_filtered> <wait_for_event> <wait_1> <wait_for_sigstop> <move_out_of_jump_pad> <stop_all_lwps> <start_step_over> <complete_ongoing_step_over> <proceed_all_lwps> <unstop_all_lwps>: Declare. Update the callers below. * linux-low.cc (linux_process_target::attach): Update. (linux_process_target::stabilize_threads): Ditto. (linux_process_target::wait): Ditto.
2020-04-02 15:11:22 +02:00
void
linux_process_target::unstop_all_lwps (int unsuspend, lwp_info *except)
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
{
if (debug_threads)
{
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_enter ();
Teach linux gdbserver to step-over-breakpoints. * linux-low.c (can_hardware_single_step): New. (supports_breakpoints): New. (handle_extended_wait): If stopping threads, read the stop pc of the new cloned LWP. (get_pc): New. (get_stop_pc): Add `lwp' parameter. Handle it. Bail out if the low target doesn't support retrieving the PC. (add_lwp): Set last_resume_kind to resume_continue. (linux_attach_lwp_1): Adjust comments. Always set stop_expected. (linux_attach): Don't clear stop_expected. Set the lwp's last_resume_kind to resume_stop. (linux_detach_one_lwp): Don't check for removed breakpoints. (check_removed_breakpoint): Delete. (status_pending_p): Rename to ... (status_pending_p_callback): ... this. Don't check for removed breakpoints. Don't consider threads that are stopped from GDB's perspective. (linux_wait_for_lwp): Always read the stop_pc here. (cancel_breakpoint): New. (step_over_bkpt): New global. (linux_wait_for_event_1): Implement stepping over breakpoints. (gdb_wants_lwp_stopped): New. (gdb_wants_all_stopped): New. (linux_wait_1): Tag threads as gdb-wants-stopped. Cancel finished single-step traps here. Store the thread's last reported target wait status. (send_sigstop): Don't clear stop_expected. Always set it, instead. (mark_lwp_dead): Remove reference to pending_is_breakpoint. (cancel_finished_single_step): New. (cancel_finished_single_steps): New. (wait_for_sigstop): Don't cancel finished single-step traps here. (linux_resume_one_lwp): Don't check for removed breakpoints. Don't set `step' on non-hardware step archs. (linux_set_resume_request): Ignore resume_stop requests if already stopping or stopped. Set the lwp's last_resume_kind. (resume_status_pending_p): Don't check for removed breakpoints. (need_step_over_p): New. (start_step_over): New. (finish_step_over): New. (linux_resume_one_thread): Always queue a sigstop for resume_stop requests. Clear the thread's last reported target waitstatus. Don't use the `suspended' flag. Don't consider pending breakpoints. (linux_resume): Start a step-over if necessary. (proceed_one_lwp): New. (proceed_all_lwps): New. (unstop_all_lwps): New. * linux-low.h (struct lwp_info): Rewrite comment for the `suspended' flag. Add the `stop_pc' field. Delete the `pending_stop_pc' field. Tweak the `stepping' flag's comment. Add `'last_resume_kind' and `need_step_over' fields. * inferiors.c (struct thread_info): Delete, moved elsewhere. * mem-break.c (struct breakpoint): Delete `reinserting' flag. Delete `breakpoint_to_reinsert' field. New flag `inserted'. (set_raw_breakpoint_at): New. (set_breakpoint_at): Rewrite to use it. (reinsert_breakpoint_handler): Delete. (set_reinsert_breakpoint): New. (reinsert_breakpoint_by_bp): Delete. (delete_reinsert_breakpoints): New. (uninsert_breakpoint): Rewrite. (uninsert_breakpoints_at): New. (reinsert_breakpoint): Rewrite. (reinsert_breakpoints_at): New. (check_breakpoints): Rewrite. (breakpoint_here): New. (breakpoint_inserted_here): New. (check_mem_read): Adjust. * mem-break.h (breakpoints_supported, breakpoint_here) (breakpoint_inserted_here, set_reinsert_breakpoint): Declare. (reinsert_breakpoint_by_bp): Delete declaration. (delete_reinsert_breakpoints): Declare. (reinsert_breakpoint): Delete declaration. (reinsert_breakpoints_at): Declare. (uninsert_breakpoint): Delete declaration. (uninsert_breakpoints_at): Declare. (check_breakpoints): Adjust prototype. * server.h: Adjust include order. (struct thread_info): Declare here. Add a `last_status' field.
2010-03-24 01:05:03 +01:00
if (except)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("unstopping all lwps, except=(LWP %ld)\n",
Remove all_lwps global. * inferiors.h (ptid_of): Move here from linux-low.h. (pid_of, lwpid_of): Ditto. * linux-aarch64-low.c (debug_reg_change_callback): Update, "entry" parameter is a struct thread_info * now. (aarch64_notify_debug_reg_change): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior instead of &all_lwps. (aarch64_stopped_data_address): Fetch lwpid from current_inferior directly. (aarch64_linux_prepare_to_resume): Fetch ptid from thread. (aarch64_arch_setup): Fetch lwpid from current_inferior directly. * linux-arm-low.c (update_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from current_inferior directly. (arm_insert_point): Pass &all_threads to find_inferior instead of &all_lwps. (arm_remove_point): Ditto. (arm_stopped_by_watchpoint): Fetch lwp from current_inferior. (arm_prepare_to_resume): Fetch pid from thread. (arm_read_description): Fetch lwpid from current_inferior directly. * linux-low.c (all_lwps): Delete. (delete_lwp): Delete call to remove_inferior. (handle_extended_wait): Fetch lwpid from thread. (add_lwp): Don't set lwp->entry.id. Remove call to add_inferior_to_list. (linux_attach_lwp_1): Fetch pid from current_inferior directly. (linux_kill_one_lwp): Fetch ptid,lwpid from thread. (kill_one_lwp_callback): Ditto. (linux_kill): Don't dereference NULL pointer. Fetch ptid,lwpid from thread. (get_detach_signal): Fetch ptid from thread. (linux_detach_one_lwp): Fetch ptid,lwpid from thread. Simplify call to regcache_invalidate_thread. (delete_lwp_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (linux_mourn): Pass &all_threads to find_inferior instead of &all_lwps. (status_pending_p_callback): Update, "entry" parameter is a struct thread_info * now. Fetch ptid from thread. (find_lwp_pid): Update, "entry" parameter is a struct thread_info * now. (linux_wait_for_lwp): Fetch pid from thread. (linux_fast_tracepoint_collecting): Fetch lwpid from thread. (maybe_move_out_of_jump_pad): Fetch lwpid from current_inferior. (enqueue_one_deferred_signal): Fetch lwpid from thread. (dequeue_one_deferred_signal): Ditto. (cancel_breakpoint): Fetch ptid from current_inferior. (linux_wait_for_event): Pass &all_threads to find_inferior, not &all_lwps. Fetch ptid, lwpid from thread. (count_events_callback): Update, "entry" parameter is a struct thread_info * now. (select_singlestep_lwp_callback): Ditto. (select_event_lwp_callback): Ditto. (cancel_breakpoints_callback): Ditto. (linux_cancel_breakpoints): Pass &all_threads to find_inferior, not &all_lwps. (select_event_lwp): Ditto. Fetch ptid from event_thread. (unsuspend_one_lwp): Update, "entry" parameter is a struct thread_info * now. (unsuspend_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (linux_stabilize_threads): Ditto. And for for_each_inferior. Fetch lwpid from thread, not lwp. (linux_wait_1): Fetch ptid, lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (send_sigstop): Fetch lwpid from thread, not lwp. (send_sigstop_callback): Update, "entry" parameter is a struct thread_info * now. (suspend_and_send_sigstop_callback): Ditto. (wait_for_sigstop): Ditto. Fetch ptid, lwpid from thread, lwp. (stuck_in_jump_pad_callback): Update, "entry" parameter is a struct thread_info * now. (move_out_of_jump_pad_callback): Ditto. Fetch ptid, lwpid from thread, lwp. (lwp_running): Update, "entry" parameter is a struct thread_info * now. (stop_all_lwps): Fetch ptid from thread. Pass &all_threads to find_inferior, for_each_inferior, not &all_lwps. (linux_resume_one_lwp): Fetch lwpid from thread. (linux_set_resume_request): Update, "entry" parameter is a struct thread_info * now. Fetch pid, lwpid from thread. (resume_status_pending_p): Update, "entry" parameter is a struct thread_info * now. (need_step_over_p): Ditto. Fetch lwpid from thread. (start_step_over): Fetch lwpid from thread. (linux_resume_one_thread): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (linux_resume): Pass &all_threads to find_inferior, not &all_lwps. (proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. Fetch lwpid from thread. (unsuspend_and_proceed_one_lwp): Update, "entry" parameter is a struct thread_info * now. (proceed_all_lwps): Pass &all_threads to find_inferior, not &all_lwps. (unstop_all_lwps): Ditto. Fetch lwpid from thread. (regsets_fetch_inferior_registers): Fetch lwpid from current_inferior directly. (regsets_store_inferior_registers): Ditto. (fetch_register, store_register): Ditto. (linux_read_memory, linux_write_memory): Ditto. (linux_request_interrupt): Ditto. (linux_read_auxv): Ditto. (linux_xfer_siginfo): Ditto. (linux_qxfer_spu): Ditto. (linux_qxfer_libraries_svr4): Ditto. * linux-low.h (ptid_of, pid_of, lwpid_of): Delete, moved to inferiors.h. (get_lwp): Delete. (get_thread_lwp): Update. (struct lwp_info): Delete member "entry". Simplify comment for member "thread". (all_lwps): Delete. * linux-mips-low.c (mips_read_description): Fetch lwpid from current_inferior directly. (update_watch_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (mips_linux_prepare_to_resume): Fetch ptid from thread. (mips_insert_point): Fetch lwpid from current_inferior. Pass &all_threads to find_inferior, not &all_lwps. (mips_remove_point): Pass &all_threads to find_inferior, not &all_lwps. (mips_stopped_by_watchpoint): Fetch lwpid from current_inferior directly. (mips_stopped_data_address): Ditto. * linux-s390-low.c (s390_arch_setup): Fetch pid from current_inferior directly. * linux-tile-low.c (tile_arch_setup): Ditto. * linux-x86-low.c (x86_get_thread_area): Fetch lwpid from thread. (update_debug_registers_callback): Update, "entry" parameter is a struct thread_info * now. Fetch pid from thread. (i386_dr_low_set_addr): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_addr): Fetch ptid from current_inferior directly. (i386_dr_low_set_control): Fetch pid from current_inferior directly. Pass &all_threads to find_inferior, not &all_lwps. (i386_dr_low_get_control): Fetch ptid from current_inferior directly. (i386_dr_low_get_status): Ditto. (x86_linux_prepare_to_resume): Fetch ptid from thread. (x86_siginfo_fixup): Fetch lwpid from current_inferior directly. (x86_linux_read_description): Ditto. * proc-service.c (ps_getpid): Fetch pid from current_inferior directly.
2014-02-20 21:23:26 +01:00
lwpid_of (get_lwp_thread (except)));
else
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("unstopping all lwps\n");
}
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
if (unsuspend)
for_each_thread ([&] (thread_info *thread)
{
unsuspend_and_proceed_one_lwp (thread, except);
});
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
else
for_each_thread ([&] (thread_info *thread)
{
proceed_one_lwp (thread, except);
});
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
if (debug_threads)
{
debug_printf ("unstop_all_lwps done\n");
debug_exit ();
}
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
}
#ifdef HAVE_LINUX_REGSETS
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
#define use_linux_regsets 1
/* Returns true if REGSET has been disabled. */
static int
regset_disabled (struct regsets_info *info, struct regset_info *regset)
{
return (info->disabled_regsets != NULL
&& info->disabled_regsets[regset - info->regsets]);
}
/* Disable REGSET. */
static void
disable_regset (struct regsets_info *info, struct regset_info *regset)
{
int dr_offset;
dr_offset = regset - info->regsets;
if (info->disabled_regsets == NULL)
Add casts to memory allocation related calls Most allocation functions (if not all) return a void* pointing to the allocated memory. In C++, we need to add an explicit cast when assigning the result to a pointer to another type (which is the case more often than not). The content of this patch is taken from Pedro's branch, from commit "(mostly) auto-generated patch to insert casts needed for C++". I validated that the changes make sense and manually reflowed the code to make it respect the coding style. I also found multiple places where I could use XNEW/XNEWVEC/XRESIZEVEC/etc. Thanks a lot to whoever did that automated script to insert casts, doing it completely by hand would have taken a ridiculous amount of time. Only files built on x86 with --enable-targets=all are modified. This means that all other -nat.c files are untouched and will have to be dealt with later by using appropiate compilers. Or maybe we can try to build them with a regular g++ just to know where to add casts, I don't know. I built-tested this with --enable-targets=all and reg-tested. Here's the changelog entry, which was not too bad to make despite the size, thanks to David Malcom's script. I fixed some bits by hand, but there might be some wrong parts left (hopefully not). gdb/ChangeLog: * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Add cast to allocation result assignment. * ada-exp.y (write_object_renaming): Likewise. (write_ambiguous_var): Likewise. (ada_nget_field_index): Likewise. (write_var_or_type): Likewise. * ada-lang.c (ada_decode_symbol): Likewise. (ada_value_assign): Likewise. (value_pointer): Likewise. (cache_symbol): Likewise. (add_nonlocal_symbols): Likewise. (ada_name_for_lookup): Likewise. (symbol_completion_add): Likewise. (ada_to_fixed_type_1): Likewise. (ada_get_next_arg): Likewise. (defns_collected): Likewise. * ada-lex.l (processId): Likewise. (processString): Likewise. * ada-tasks.c (read_known_tasks_array): Likewise. (read_known_tasks_list): Likewise. * ada-typeprint.c (decoded_type_name): Likewise. * addrmap.c (addrmap_mutable_create_fixed): Likewise. * amd64-tdep.c (amd64_push_arguments): Likewise. (amd64_displaced_step_copy_insn): Likewise. (amd64_classify_insn_at): Likewise. (amd64_relocate_instruction): Likewise. * amd64obsd-tdep.c (amd64obsd_sigtramp_p): Likewise. * arch-utils.c (simple_displaced_step_copy_insn): Likewise. (initialize_current_architecture): Likewise. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * arm-symbian-tdep.c (arm_symbian_osabi_sniffer): Likewise. * arm-tdep.c (arm_exidx_new_objfile): Likewise. (arm_push_dummy_call): Likewise. (extend_buffer_earlier): Likewise. (arm_adjust_breakpoint_address): Likewise. (arm_skip_stub): Likewise. * auto-load.c (filename_is_in_pattern): Likewise. (maybe_add_script_file): Likewise. (maybe_add_script_text): Likewise. (auto_load_objfile_script_1): Likewise. * auxv.c (ld_so_xfer_auxv): Likewise. * ax-general.c (new_agent_expr): Likewise. (grow_expr): Likewise. (ax_reg_mask): Likewise. * bcache.c (bcache_full): Likewise. * breakpoint.c (program_breakpoint_here_p): Likewise. * btrace.c (parse_xml_raw): Likewise. * build-id.c (build_id_to_debug_bfd): Likewise. * buildsym.c (end_symtab_with_blockvector): Likewise. * c-exp.y (string_exp): Likewise. (qualified_name): Likewise. (write_destructor_name): Likewise. (operator_stoken): Likewise. (parse_number): Likewise. (scan_macro_expansion): Likewise. (yylex): Likewise. (c_print_token): Likewise. * c-lang.c (c_get_string): Likewise. (emit_numeric_character): Likewise. * charset.c (wchar_iterate): Likewise. * cli/cli-cmds.c (complete_command): Likewise. (make_command): Likewise. * cli/cli-dump.c (restore_section_callback): Likewise. (restore_binary_file): Likewise. * cli/cli-interp.c (cli_interpreter_exec): Likewise. * cli/cli-script.c (execute_control_command): Likewise. * cli/cli-setshow.c (do_set_command): Likewise. * coff-pe-read.c (add_pe_forwarded_sym): Likewise. (read_pe_exported_syms): Likewise. * coffread.c (coff_read_struct_type): Likewise. (coff_read_enum_type): Likewise. * common/btrace-common.c (btrace_data_append): Likewise. * common/buffer.c (buffer_grow): Likewise. * common/filestuff.c (gdb_fopen_cloexec): Likewise. * common/format.c (parse_format_string): Likewise. * common/gdb_vecs.c (delim_string_to_char_ptr_vec_append): Likewise. * common/xml-utils.c (xml_escape_text): Likewise. * compile/compile-object-load.c (copy_sections): Likewise. (compile_object_load): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * completer.c (filename_completer): Likewise. * corefile.c (read_memory_typed_address): Likewise. (write_memory_unsigned_integer): Likewise. (write_memory_signed_integer): Likewise. (complete_set_gnutarget): Likewise. * corelow.c (get_core_register_section): Likewise. * cp-name-parser.y (d_grab): Likewise. (allocate_info): Likewise. (cp_new_demangle_parse_info): Likewise. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Likewise. (cp_lookup_symbol_in_namespace): Likewise. (lookup_namespace_scope): Likewise. (find_symbol_in_baseclass): Likewise. (cp_lookup_nested_symbol): Likewise. (cp_lookup_transparent_type_loop): Likewise. * cp-support.c (copy_string_to_obstack): Likewise. (make_symbol_overload_list): Likewise. (make_symbol_overload_list_namespace): Likewise. (make_symbol_overload_list_adl_namespace): Likewise. (first_component_command): Likewise. * cp-valprint.c (cp_print_value): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * d-exp.y (StringExp): Likewise. * d-namespace.c (d_lookup_symbol_in_module): Likewise. (lookup_module_scope): Likewise. (find_symbol_in_baseclass): Likewise. (d_lookup_nested_symbol): Likewise. * dbxread.c (find_stab_function_addr): Likewise. (read_dbx_symtab): Likewise. (dbx_end_psymtab): Likewise. (cp_set_block_scope): Likewise. * dcache.c (dcache_alloc): Likewise. * demangle.c (_initialize_demangler): Likewise. * dicos-tdep.c (dicos_load_module_p): Likewise. * dictionary.c (dict_create_hashed_expandable): Likewise. (dict_create_linear_expandable): Likewise. (expand_hashtable): Likewise. (add_symbol_linear_expandable): Likewise. * dwarf2-frame.c (add_cie): Likewise. (add_fde): Likewise. (dwarf2_build_frame_info): Likewise. * dwarf2expr.c (dwarf_expr_grow_stack): Likewise. (dwarf_expr_fetch_address): Likewise. (add_piece): Likewise. (execute_stack_op): Likewise. * dwarf2loc.c (chain_candidate): Likewise. (dwarf_entry_parameter_to_value): Likewise. (read_pieced_value): Likewise. (write_pieced_value): Likewise. * dwarf2read.c (dwarf2_read_section): Likewise. (add_type_unit): Likewise. (read_comp_units_from_section): Likewise. (fixup_go_packaging): Likewise. (dwarf2_compute_name): Likewise. (dwarf2_physname): Likewise. (create_dwo_unit_in_dwp_v1): Likewise. (create_dwo_unit_in_dwp_v2): Likewise. (read_func_scope): Likewise. (read_call_site_scope): Likewise. (dwarf2_attach_fields_to_type): Likewise. (process_structure_scope): Likewise. (mark_common_block_symbol_computed): Likewise. (read_common_block): Likewise. (abbrev_table_read_table): Likewise. (guess_partial_die_structure_name): Likewise. (fixup_partial_die): Likewise. (add_file_name): Likewise. (dwarf2_const_value_data): Likewise. (dwarf2_const_value_attr): Likewise. (build_error_marker_type): Likewise. (guess_full_die_structure_name): Likewise. (anonymous_struct_prefix): Likewise. (typename_concat): Likewise. (dwarf2_canonicalize_name): Likewise. (dwarf2_name): Likewise. (write_constant_as_bytes): Likewise. (dwarf2_fetch_constant_bytes): Likewise. (copy_string): Likewise. (parse_macro_definition): Likewise. * elfread.c (elf_symfile_segments): Likewise. (elf_rel_plt_read): Likewise. (elf_gnu_ifunc_resolve_by_cache): Likewise. (elf_gnu_ifunc_resolve_by_got): Likewise. (elf_read_minimal_symbols): Likewise. (elf_gnu_ifunc_record_cache): Likewise. * event-top.c (top_level_prompt): Likewise. (command_line_handler): Likewise. * exec.c (resize_section_table): Likewise. * expprint.c (print_subexp_standard): Likewise. * fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise. * findcmd.c (parse_find_args): Likewise. * findvar.c (address_from_register): Likewise. * frame.c (get_prev_frame_always): Likewise. * gdb_bfd.c (gdb_bfd_ref): Likewise. (get_section_descriptor): Likewise. * gdb_obstack.c (obconcat): Likewise. (obstack_strdup): Likewise. * gdbtypes.c (lookup_function_type_with_arguments): Likewise. (create_set_type): Likewise. (lookup_unsigned_typename): Likewise. (lookup_signed_typename): Likewise. (resolve_dynamic_union): Likewise. (resolve_dynamic_struct): Likewise. (add_dyn_prop): Likewise. (copy_dynamic_prop_list): Likewise. (arch_flags_type): Likewise. (append_composite_type_field_raw): Likewise. * gdbtypes.h (INIT_FUNC_SPECIFIC): Likewise. * gnu-v3-abi.c (gnuv3_rtti_type): Likewise. * go-exp.y (string_exp): Likewise. * go-lang.c (go_demangle): Likewise. * guile/guile.c (compute_scheme_string): Likewise. * guile/scm-cmd.c (gdbscm_parse_command_name): Likewise. (gdbscm_canonicalize_command_name): Likewise. * guile/scm-ports.c (ioscm_init_stdio_buffers): Likewise. (ioscm_init_memory_port): Likewise. (ioscm_reinit_memory_port): Likewise. * guile/scm-utils.c (gdbscm_gc_xstrdup): Likewise. (gdbscm_gc_dup_argv): Likewise. * h8300-tdep.c (h8300_push_dummy_call): Likewise. * hppa-tdep.c (internalize_unwinds): Likewise. (read_unwind_info): Likewise. * i386-cygwin-tdep.c (core_process_module_section): Likewise. (windows_core_xfer_shared_libraries): Likewise. * i386-tdep.c (i386_displaced_step_copy_insn): Likewise. (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * i386obsd-tdep.c (i386obsd_sigtramp_p): Likewise. * inf-child.c (inf_child_fileio_readlink): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_store_register): Likewise. * infrun.c (follow_exec): Likewise. (displaced_step_prepare_throw): Likewise. (save_stop_context): Likewise. (save_infcall_suspend_state): Likewise. * jit.c (jit_read_descriptor): Likewise. (jit_read_code_entry): Likewise. (jit_symtab_line_mapping_add_impl): Likewise. (finalize_symtab): Likewise. (jit_unwind_reg_get_impl): Likewise. * jv-exp.y (QualifiedName): Likewise. * jv-lang.c (get_java_utf8_name): Likewise. (type_from_class): Likewise. (java_demangle_type_signature): Likewise. (java_class_name_from_physname): Likewise. * jv-typeprint.c (java_type_print_base): Likewise. * jv-valprint.c (java_value_print): Likewise. * language.c (add_language): Likewise. * linespec.c (add_sal_to_sals_basic): Likewise. (add_sal_to_sals): Likewise. (decode_objc): Likewise. (find_linespec_symbols): Likewise. * linux-fork.c (fork_save_infrun_state): Likewise. * linux-nat.c (linux_nat_detach): Likewise. (linux_nat_fileio_readlink): Likewise. * linux-record.c (record_linux_sockaddr): Likewise. (record_linux_msghdr): Likewise. (Do): Likewise. * linux-tdep.c (linux_core_info_proc_mappings): Likewise. (linux_collect_regset_section_cb): Likewise. (linux_get_siginfo_data): Likewise. * linux-thread-db.c (try_thread_db_load_from_pdir_1): Likewise. (try_thread_db_load_from_dir): Likewise. (thread_db_load_search): Likewise. (info_auto_load_libthread_db): Likewise. * m32c-tdep.c (m32c_m16c_address_to_pointer): Likewise. (m32c_m16c_pointer_to_address): Likewise. * m68hc11-tdep.c (m68hc11_pseudo_register_write): Likewise. * m68k-tdep.c (m68k_get_longjmp_target): Likewise. * machoread.c (macho_check_dsym): Likewise. * macroexp.c (resize_buffer): Likewise. (gather_arguments): Likewise. (maybe_expand): Likewise. * macrotab.c (new_macro_key): Likewise. (new_source_file): Likewise. (new_macro_definition): Likewise. * mdebugread.c (parse_symbol): Likewise. (parse_type): Likewise. (parse_partial_symbols): Likewise. (psymtab_to_symtab_1): Likewise. * mem-break.c (default_memory_insert_breakpoint): Likewise. * mi/mi-cmd-break.c (mi_argv_to_format): Likewise. * mi/mi-main.c (mi_cmd_data_read_memory): Likewise. (mi_cmd_data_read_memory_bytes): Likewise. (mi_cmd_data_write_memory_bytes): Likewise. (mi_cmd_trace_frame_collected): Likewise. * mi/mi-parse.c (mi_parse_argv): Likewise. (mi_parse): Likewise. * minidebug.c (lzma_open): Likewise. (lzma_pread): Likewise. * mips-tdep.c (mips_read_fp_register_single): Likewise. (mips_print_fp_register): Likewise. * mipsnbsd-tdep.c (mipsnbsd_get_longjmp_target): Likewise. * mipsread.c (read_alphacoff_dynamic_symtab): Likewise. * mt-tdep.c (mt_register_name): Likewise. (mt_registers_info): Likewise. (mt_push_dummy_call): Likewise. * namespace.c (add_using_directive): Likewise. * nat/linux-btrace.c (perf_event_read): Likewise. (linux_enable_bts): Likewise. * nat/linux-osdata.c (linux_common_core_of_thread): Likewise. * nat/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Likewise. * nto-tdep.c (nto_find_and_open_solib): Likewise. (nto_parse_redirection): Likewise. * objc-lang.c (objc_demangle): Likewise. (find_methods): Likewise. * objfiles.c (get_objfile_bfd_data): Likewise. (set_objfile_main_name): Likewise. (allocate_objfile): Likewise. (objfile_relocate): Likewise. (update_section_map): Likewise. * osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Likewise. * p-exp.y (exp): Likewise. (yylex): Likewise. * p-valprint.c (pascal_object_print_value): Likewise. * parse.c (initialize_expout): Likewise. (mark_completion_tag): Likewise. (copy_name): Likewise. (parse_float): Likewise. (type_stack_reserve): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. (ppu2spu_prev_register): Likewise. * ppc-ravenscar-thread.c (supply_register_at_address): Likewise. * printcmd.c (printf_wide_c_string): Likewise. (printf_pointer): Likewise. * probe.c (parse_probes): Likewise. * python/py-cmd.c (gdbpy_parse_command_name): Likewise. (cmdpy_init): Likewise. * python/py-gdb-readline.c (gdbpy_readline_wrapper): Likewise. * python/py-symtab.c (set_sal): Likewise. * python/py-unwind.c (pyuw_sniffer): Likewise. * python/python.c (python_interactive_command): Likewise. (compute_python_string): Likewise. * ravenscar-thread.c (get_running_thread_id): Likewise. * record-full.c (record_full_exec_insn): Likewise. (record_full_core_open_1): Likewise. * regcache.c (regcache_raw_read_signed): Likewise. (regcache_raw_read_unsigned): Likewise. (regcache_cooked_read_signed): Likewise. (regcache_cooked_read_unsigned): Likewise. * remote-fileio.c (remote_fileio_func_open): Likewise. (remote_fileio_func_rename): Likewise. (remote_fileio_func_unlink): Likewise. (remote_fileio_func_stat): Likewise. (remote_fileio_func_system): Likewise. * remote-mips.c (mips_xfer_memory): Likewise. (mips_load_srec): Likewise. (pmon_end_download): Likewise. * remote.c (new_remote_state): Likewise. (map_regcache_remote_table): Likewise. (remote_register_number_and_offset): Likewise. (init_remote_state): Likewise. (get_memory_packet_size): Likewise. (remote_pass_signals): Likewise. (remote_program_signals): Likewise. (remote_start_remote): Likewise. (remote_check_symbols): Likewise. (remote_query_supported): Likewise. (extended_remote_attach): Likewise. (process_g_packet): Likewise. (store_registers_using_G): Likewise. (putpkt_binary): Likewise. (read_frame): Likewise. (compare_sections_command): Likewise. (remote_hostio_pread): Likewise. (remote_hostio_readlink): Likewise. (remote_file_put): Likewise. (remote_file_get): Likewise. (remote_pid_to_exec_file): Likewise. (_initialize_remote): Likewise. * rs6000-aix-tdep.c (rs6000_aix_ld_info_to_xml): Likewise. (rs6000_aix_core_xfer_shared_libraries_aix): Likewise. * rs6000-tdep.c (ppc_displaced_step_copy_insn): Likewise. (bfd_uses_spe_extensions): Likewise. * s390-linux-tdep.c (s390_displaced_step_copy_insn): Likewise. * score-tdep.c (score7_malloc_and_get_memblock): Likewise. * solib-dsbt.c (decode_loadmap): Likewise. (fetch_loadmap): Likewise. (scan_dyntag): Likewise. (enable_break): Likewise. (dsbt_relocate_main_executable): Likewise. * solib-frv.c (fetch_loadmap): Likewise. (enable_break2): Likewise. (frv_relocate_main_executable): Likewise. * solib-spu.c (spu_relocate_main_executable): Likewise. (spu_bfd_open): Likewise. * solib-svr4.c (lm_info_read): Likewise. (read_program_header): Likewise. (find_program_interpreter): Likewise. (scan_dyntag): Likewise. (elf_locate_base): Likewise. (open_symbol_file_object): Likewise. (read_program_headers_from_bfd): Likewise. (svr4_relocate_main_executable): Likewise. * solib-target.c (solib_target_relocate_section_addresses): Likewise. * solib.c (solib_find_1): Likewise. (exec_file_find): Likewise. (solib_find): Likewise. * source.c (openp): Likewise. (print_source_lines_base): Likewise. (forward_search_command): Likewise. * sparc-ravenscar-thread.c (supply_register_at_address): Likewise. * spu-tdep.c (spu2ppu_prev_register): Likewise. (spu_get_overlay_table): Likewise. * stabsread.c (patch_block_stabs): Likewise. (define_symbol): Likewise. (again:): Likewise. (read_member_functions): Likewise. (read_one_struct_field): Likewise. (read_enum_type): Likewise. (common_block_start): Likewise. * stack.c (read_frame_arg): Likewise. (backtrace_command): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. * symfile.c (syms_from_objfile_1): Likewise. (find_separate_debug_file): Likewise. (load_command): Likewise. (load_progress): Likewise. (load_section_callback): Likewise. (reread_symbols): Likewise. (add_filename_language): Likewise. (allocate_compunit_symtab): Likewise. (read_target_long_array): Likewise. (simple_read_overlay_table): Likewise. * symtab.c (symbol_set_names): Likewise. (resize_symbol_cache): Likewise. (rbreak_command): Likewise. (completion_list_add_name): Likewise. (completion_list_objc_symbol): Likewise. (add_filename_to_list): Likewise. * target-descriptions.c (maint_print_c_tdesc_cmd): Likewise. * target-memory.c (target_write_memory_blocks): Likewise. * target.c (target_read_string): Likewise. (read_whatever_is_readable): Likewise. (target_read_alloc_1): Likewise. (simple_search_memory): Likewise. (target_fileio_read_alloc_1): Likewise. * tilegx-tdep.c (tilegx_push_dummy_call): Likewise. * top.c (command_line_input): Likewise. * tracefile-tfile.c (tfile_fetch_registers): Likewise. * tracefile.c (tracefile_fetch_registers): Likewise. * tracepoint.c (add_memrange): Likewise. (init_collection_list): Likewise. (add_aexpr): Likewise. (trace_dump_actions): Likewise. (parse_trace_status): Likewise. (parse_tracepoint_definition): Likewise. (parse_tsv_definition): Likewise. (parse_static_tracepoint_marker_definition): Likewise. * tui/tui-file.c (tui_sfileopen): Likewise. (tui_file_adjust_strbuf): Likewise. * tui/tui-io.c (tui_expand_tabs): Likewise. * tui/tui-source.c (tui_set_source_content): Likewise. * typeprint.c (find_global_typedef): Likewise. * ui-file.c (do_ui_file_xstrdup): Likewise. (ui_file_obsavestring): Likewise. (mem_file_write): Likewise. * utils.c (make_hex_string): Likewise. (get_regcomp_error): Likewise. (puts_filtered_tabular): Likewise. (gdb_realpath_keepfile): Likewise. (ldirname): Likewise. (gdb_bfd_errmsg): Likewise. (substitute_path_component): Likewise. * valops.c (search_struct_method): Likewise. (find_oload_champ_namespace_loop): Likewise. * valprint.c (print_decimal_chars): Likewise. (read_string): Likewise. (generic_emit_char): Likewise. * varobj.c (varobj_delete): Likewise. (varobj_value_get_print_value): Likewise. * vaxobsd-tdep.c (vaxobsd_sigtramp_sniffer): Likewise. * windows-tdep.c (display_one_tib): Likewise. * xcoffread.c (read_xcoff_symtab): Likewise. (process_xcoff_symbol): Likewise. (swap_sym): Likewise. (scan_xcoff_symtab): Likewise. (xcoff_initial_scan): Likewise. * xml-support.c (gdb_xml_end_element): Likewise. (xml_process_xincludes): Likewise. (xml_fetch_content_from_file): Likewise. * xml-syscall.c (xml_list_of_syscalls): Likewise. * xstormy16-tdep.c (xstormy16_push_dummy_call): Likewise. gdb/gdbserver/ChangeLog: * ax.c (gdb_parse_agent_expr): Add cast to allocation result assignment. (gdb_unparse_agent_expr): Likewise. * hostio.c (require_data): Likewise. (handle_pread): Likewise. * linux-low.c (disable_regset): Likewise. (fetch_register): Likewise. (store_register): Likewise. (get_dynamic): Likewise. (linux_qxfer_libraries_svr4): Likewise. * mem-break.c (delete_fast_tracepoint_jump): Likewise. (set_fast_tracepoint_jump): Likewise. (uninsert_fast_tracepoint_jumps_at): Likewise. (reinsert_fast_tracepoint_jumps_at): Likewise. (validate_inserted_breakpoint): Likewise. (clone_agent_expr): Likewise. * regcache.c (init_register_cache): Likewise. * remote-utils.c (putpkt_binary_1): Likewise. (decode_M_packet): Likewise. (decode_X_packet): Likewise. (look_up_one_symbol): Likewise. (relocate_instruction): Likewise. (monitor_output): Likewise. * server.c (handle_search_memory): Likewise. (handle_qxfer_exec_file): Likewise. (handle_qxfer_libraries): Likewise. (handle_qxfer): Likewise. (handle_query): Likewise. (handle_v_cont): Likewise. (handle_v_run): Likewise. (captured_main): Likewise. * target.c (write_inferior_memory): Likewise. * thread-db.c (try_thread_db_load_from_dir): Likewise. * tracepoint.c (init_trace_buffer): Likewise. (add_tracepoint_action): Likewise. (add_traceframe): Likewise. (add_traceframe_block): Likewise. (cmd_qtdpsrc): Likewise. (cmd_qtdv): Likewise. (cmd_qtstatus): Likewise. (response_source): Likewise. (response_tsv): Likewise. (cmd_qtnotes): Likewise. (gdb_collect): Likewise. (initialize_tracepoint): Likewise.
2015-09-25 20:08:06 +02:00
info->disabled_regsets = (char *) xcalloc (1, info->num_regsets);
info->disabled_regsets[dr_offset] = 1;
}
static int
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
regsets_fetch_inferior_registers (struct regsets_info *regsets_info,
struct regcache *regcache)
{
struct regset_info *regset;
int saw_general_regs = 0;
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
int pid;
Add x86 AVX support to gdbserver. 2010-04-07 H.J. Lu <hongjiu.lu@intel.com> * Makefile.in (clean): Updated. (i386-avx.o): New. (i386-avx.c): Likewise. (i386-avx-linux.o): Likewise. (i386-avx-linux.c): Likewise. (amd64-avx.o): Likewise. (amd64-avx.c): Likewise. (amd64-avx-linux.o): Likewise. (amd64-avx-linux.c): Likewise. * configure.srv (srv_i386_regobj): Add i386-avx.o. (srv_i386_linux_regobj): Add i386-avx-linux.o. (srv_amd64_regobj): Add amd64-avx.o. (srv_amd64_linux_regobj): Add amd64-avx-linux.o. (srv_i386_32bit_xmlfiles): Add i386/32bit-avx.xml. (srv_i386_64bit_xmlfiles): Add i386/64bit-avx.xml. (srv_i386_xmlfiles): Add i386/i386-avx.xml. (srv_amd64_xmlfiles): Add i386/amd64-avx.xml. (srv_i386_linux_xmlfiles): Add i386/i386-avx-linux.xml. (srv_amd64_linux_xmlfiles): Add i386/amd64-avx-linux.xml. * i387-fp.c: Include "i386-xstate.h". (i387_xsave): New. (i387_cache_to_xsave): Likewise. (i387_xsave_to_cache): Likewise. (x86_xcr0): Likewise. * i387-fp.h (i387_cache_to_xsave): Likewise. (i387_xsave_to_cache): Likewise. (x86_xcr0): Likewise. * linux-arm-low.c (target_regsets): Initialize nt_type to 0. * linux-crisv32-low.c (target_regsets): Likewise. * linux-m68k-low.c (target_regsets): Likewise. * linux-mips-low.c (target_regsets): Likewise. * linux-ppc-low.c (target_regsets): Likewise. * linux-s390-low.c (target_regsets): Likewise. * linux-sh-low.c (target_regsets): Likewise. * linux-sparc-low.c (target_regsets): Likewise. * linux-xtensa-low.c (target_regsets): Likewise. * linux-low.c: Include <sys/uio.h>. (regsets_fetch_inferior_registers): Support nt_type. (regsets_store_inferior_registers): Likewise. (linux_process_qsupported): New. (linux_target_ops): Add linux_process_qsupported. * linux-low.h (regset_info): Add nt_type. (linux_target_ops): Add process_qsupported. * linux-x86-low.c: Include "i386-xstate.h", "elf/common.h" and <sys/uio.h>. (init_registers_i386_avx_linux): New. (init_registers_amd64_avx_linux): Likewise. (xmltarget_i386_linux_no_xml): Likewise. (xmltarget_amd64_linux_no_xml): Likewise. (PTRACE_GETREGSET): Likewise. (PTRACE_SETREGSET): Likewise. (x86_fill_xstateregset): Likewise. (x86_store_xstateregset): Likewise. (use_xml): Likewise. (x86_linux_update_xmltarget): Likewise. (x86_linux_process_qsupported): Likewise. (target_regsets): Add NT_X86_XSTATE entry and Initialize nt_type. (x86_arch_setup): Don't call init_registers_amd64_linux nor init_registers_i386_linux here. Call x86_linux_update_xmltarget. (the_low_target): Add x86_linux_process_qsupported. * server.c (handle_query): Call target_process_qsupported. * target.h (target_ops): Add process_qsupported. (target_process_qsupported): New.
2010-04-07 20:49:46 +02:00
struct iovec iov;
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
pid = lwpid_of (current_thread);
for (regset = regsets_info->regsets; regset->size >= 0; regset++)
{
Add x86 AVX support to gdbserver. 2010-04-07 H.J. Lu <hongjiu.lu@intel.com> * Makefile.in (clean): Updated. (i386-avx.o): New. (i386-avx.c): Likewise. (i386-avx-linux.o): Likewise. (i386-avx-linux.c): Likewise. (amd64-avx.o): Likewise. (amd64-avx.c): Likewise. (amd64-avx-linux.o): Likewise. (amd64-avx-linux.c): Likewise. * configure.srv (srv_i386_regobj): Add i386-avx.o. (srv_i386_linux_regobj): Add i386-avx-linux.o. (srv_amd64_regobj): Add amd64-avx.o. (srv_amd64_linux_regobj): Add amd64-avx-linux.o. (srv_i386_32bit_xmlfiles): Add i386/32bit-avx.xml. (srv_i386_64bit_xmlfiles): Add i386/64bit-avx.xml. (srv_i386_xmlfiles): Add i386/i386-avx.xml. (srv_amd64_xmlfiles): Add i386/amd64-avx.xml. (srv_i386_linux_xmlfiles): Add i386/i386-avx-linux.xml. (srv_amd64_linux_xmlfiles): Add i386/amd64-avx-linux.xml. * i387-fp.c: Include "i386-xstate.h". (i387_xsave): New. (i387_cache_to_xsave): Likewise. (i387_xsave_to_cache): Likewise. (x86_xcr0): Likewise. * i387-fp.h (i387_cache_to_xsave): Likewise. (i387_xsave_to_cache): Likewise. (x86_xcr0): Likewise. * linux-arm-low.c (target_regsets): Initialize nt_type to 0. * linux-crisv32-low.c (target_regsets): Likewise. * linux-m68k-low.c (target_regsets): Likewise. * linux-mips-low.c (target_regsets): Likewise. * linux-ppc-low.c (target_regsets): Likewise. * linux-s390-low.c (target_regsets): Likewise. * linux-sh-low.c (target_regsets): Likewise. * linux-sparc-low.c (target_regsets): Likewise. * linux-xtensa-low.c (target_regsets): Likewise. * linux-low.c: Include <sys/uio.h>. (regsets_fetch_inferior_registers): Support nt_type. (regsets_store_inferior_registers): Likewise. (linux_process_qsupported): New. (linux_target_ops): Add linux_process_qsupported. * linux-low.h (regset_info): Add nt_type. (linux_target_ops): Add process_qsupported. * linux-x86-low.c: Include "i386-xstate.h", "elf/common.h" and <sys/uio.h>. (init_registers_i386_avx_linux): New. (init_registers_amd64_avx_linux): Likewise. (xmltarget_i386_linux_no_xml): Likewise. (xmltarget_amd64_linux_no_xml): Likewise. (PTRACE_GETREGSET): Likewise. (PTRACE_SETREGSET): Likewise. (x86_fill_xstateregset): Likewise. (x86_store_xstateregset): Likewise. (use_xml): Likewise. (x86_linux_update_xmltarget): Likewise. (x86_linux_process_qsupported): Likewise. (target_regsets): Add NT_X86_XSTATE entry and Initialize nt_type. (x86_arch_setup): Don't call init_registers_amd64_linux nor init_registers_i386_linux here. Call x86_linux_update_xmltarget. (the_low_target): Add x86_linux_process_qsupported. * server.c (handle_query): Call target_process_qsupported. * target.h (target_ops): Add process_qsupported. (target_process_qsupported): New.
2010-04-07 20:49:46 +02:00
void *buf, *data;
int nt_type, res;
if (regset->size == 0 || regset_disabled (regsets_info, regset))
continue;
buf = xmalloc (regset->size);
Add x86 AVX support to gdbserver. 2010-04-07 H.J. Lu <hongjiu.lu@intel.com> * Makefile.in (clean): Updated. (i386-avx.o): New. (i386-avx.c): Likewise. (i386-avx-linux.o): Likewise. (i386-avx-linux.c): Likewise. (amd64-avx.o): Likewise. (amd64-avx.c): Likewise. (amd64-avx-linux.o): Likewise. (amd64-avx-linux.c): Likewise. * configure.srv (srv_i386_regobj): Add i386-avx.o. (srv_i386_linux_regobj): Add i386-avx-linux.o. (srv_amd64_regobj): Add amd64-avx.o. (srv_amd64_linux_regobj): Add amd64-avx-linux.o. (srv_i386_32bit_xmlfiles): Add i386/32bit-avx.xml. (srv_i386_64bit_xmlfiles): Add i386/64bit-avx.xml. (srv_i386_xmlfiles): Add i386/i386-avx.xml. (srv_amd64_xmlfiles): Add i386/amd64-avx.xml. (srv_i386_linux_xmlfiles): Add i386/i386-avx-linux.xml. (srv_amd64_linux_xmlfiles): Add i386/amd64-avx-linux.xml. * i387-fp.c: Include "i386-xstate.h". (i387_xsave): New. (i387_cache_to_xsave): Likewise. (i387_xsave_to_cache): Likewise. (x86_xcr0): Likewise. * i387-fp.h (i387_cache_to_xsave): Likewise. (i387_xsave_to_cache): Likewise. (x86_xcr0): Likewise. * linux-arm-low.c (target_regsets): Initialize nt_type to 0. * linux-crisv32-low.c (target_regsets): Likewise. * linux-m68k-low.c (target_regsets): Likewise. * linux-mips-low.c (target_regsets): Likewise. * linux-ppc-low.c (target_regsets): Likewise. * linux-s390-low.c (target_regsets): Likewise. * linux-sh-low.c (target_regsets): Likewise. * linux-sparc-low.c (target_regsets): Likewise. * linux-xtensa-low.c (target_regsets): Likewise. * linux-low.c: Include <sys/uio.h>. (regsets_fetch_inferior_registers): Support nt_type. (regsets_store_inferior_registers): Likewise. (linux_process_qsupported): New. (linux_target_ops): Add linux_process_qsupported. * linux-low.h (regset_info): Add nt_type. (linux_target_ops): Add process_qsupported. * linux-x86-low.c: Include "i386-xstate.h", "elf/common.h" and <sys/uio.h>. (init_registers_i386_avx_linux): New. (init_registers_amd64_avx_linux): Likewise. (xmltarget_i386_linux_no_xml): Likewise. (xmltarget_amd64_linux_no_xml): Likewise. (PTRACE_GETREGSET): Likewise. (PTRACE_SETREGSET): Likewise. (x86_fill_xstateregset): Likewise. (x86_store_xstateregset): Likewise. (use_xml): Likewise. (x86_linux_update_xmltarget): Likewise. (x86_linux_process_qsupported): Likewise. (target_regsets): Add NT_X86_XSTATE entry and Initialize nt_type. (x86_arch_setup): Don't call init_registers_amd64_linux nor init_registers_i386_linux here. Call x86_linux_update_xmltarget. (the_low_target): Add x86_linux_process_qsupported. * server.c (handle_query): Call target_process_qsupported. * target.h (target_ops): Add process_qsupported. (target_process_qsupported): New.
2010-04-07 20:49:46 +02:00
nt_type = regset->nt_type;
if (nt_type)
{
iov.iov_base = buf;
iov.iov_len = regset->size;
data = (void *) &iov;
}
else
data = buf;
#ifndef __sparc__
res = ptrace (regset->get_request, pid,
(PTRACE_TYPE_ARG3) (long) nt_type, data);
#else
Add x86 AVX support to gdbserver. 2010-04-07 H.J. Lu <hongjiu.lu@intel.com> * Makefile.in (clean): Updated. (i386-avx.o): New. (i386-avx.c): Likewise. (i386-avx-linux.o): Likewise. (i386-avx-linux.c): Likewise. (amd64-avx.o): Likewise. (amd64-avx.c): Likewise. (amd64-avx-linux.o): Likewise. (amd64-avx-linux.c): Likewise. * configure.srv (srv_i386_regobj): Add i386-avx.o. (srv_i386_linux_regobj): Add i386-avx-linux.o. (srv_amd64_regobj): Add amd64-avx.o. (srv_amd64_linux_regobj): Add amd64-avx-linux.o. (srv_i386_32bit_xmlfiles): Add i386/32bit-avx.xml. (srv_i386_64bit_xmlfiles): Add i386/64bit-avx.xml. (srv_i386_xmlfiles): Add i386/i386-avx.xml. (srv_amd64_xmlfiles): Add i386/amd64-avx.xml. (srv_i386_linux_xmlfiles): Add i386/i386-avx-linux.xml. (srv_amd64_linux_xmlfiles): Add i386/amd64-avx-linux.xml. * i387-fp.c: Include "i386-xstate.h". (i387_xsave): New. (i387_cache_to_xsave): Likewise. (i387_xsave_to_cache): Likewise. (x86_xcr0): Likewise. * i387-fp.h (i387_cache_to_xsave): Likewise. (i387_xsave_to_cache): Likewise. (x86_xcr0): Likewise. * linux-arm-low.c (target_regsets): Initialize nt_type to 0. * linux-crisv32-low.c (target_regsets): Likewise. * linux-m68k-low.c (target_regsets): Likewise. * linux-mips-low.c (target_regsets): Likewise. * linux-ppc-low.c (target_regsets): Likewise. * linux-s390-low.c (target_regsets): Likewise. * linux-sh-low.c (target_regsets): Likewise. * linux-sparc-low.c (target_regsets): Likewise. * linux-xtensa-low.c (target_regsets): Likewise. * linux-low.c: Include <sys/uio.h>. (regsets_fetch_inferior_registers): Support nt_type. (regsets_store_inferior_registers): Likewise. (linux_process_qsupported): New. (linux_target_ops): Add linux_process_qsupported. * linux-low.h (regset_info): Add nt_type. (linux_target_ops): Add process_qsupported. * linux-x86-low.c: Include "i386-xstate.h", "elf/common.h" and <sys/uio.h>. (init_registers_i386_avx_linux): New. (init_registers_amd64_avx_linux): Likewise. (xmltarget_i386_linux_no_xml): Likewise. (xmltarget_amd64_linux_no_xml): Likewise. (PTRACE_GETREGSET): Likewise. (PTRACE_SETREGSET): Likewise. (x86_fill_xstateregset): Likewise. (x86_store_xstateregset): Likewise. (use_xml): Likewise. (x86_linux_update_xmltarget): Likewise. (x86_linux_process_qsupported): Likewise. (target_regsets): Add NT_X86_XSTATE entry and Initialize nt_type. (x86_arch_setup): Don't call init_registers_amd64_linux nor init_registers_i386_linux here. Call x86_linux_update_xmltarget. (the_low_target): Add x86_linux_process_qsupported. * server.c (handle_query): Call target_process_qsupported. * target.h (target_ops): Add process_qsupported. (target_process_qsupported): New.
2010-04-07 20:49:46 +02:00
res = ptrace (regset->get_request, pid, data, nt_type);
#endif
if (res < 0)
{
if (errno == EIO
|| (errno == EINVAL && regset->type == OPTIONAL_REGS))
{
/* If we get EIO on a regset, or an EINVAL and the regset is
optional, do not try it again for this process mode. */
disable_regset (regsets_info, regset);
}
else if (errno == ENODATA)
{
/* ENODATA may be returned if the regset is currently
not "active". This can happen in normal operation,
so suppress the warning in this case. */
}
Quiet ptrace error ESRCH in regsets_fetch_inferior_registers When I run process-dies-while-detaching.exp with GDBserver, I see many warnings printed by GDBserver, ptrace(regsets_fetch_inferior_registers) PID=26183: No such process ptrace(regsets_fetch_inferior_registers) PID=26183: No such process ptrace(regsets_fetch_inferior_registers) PID=26184: No such process ptrace(regsets_fetch_inferior_registers) PID=26184: No such process regsets_fetch_inferior_registers is called when GDBserver resumes each lwp. #2 0x0000000000428260 in regsets_fetch_inferior_registers (regsets_info=0x4690d0 <aarch64_regsets_info>, regcache=0x31832020) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:5412 #3 0x00000000004070e8 in get_thread_regcache (thread=0x31832940, fetch=fetch@entry=1) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/regcache.c:58 #4 0x0000000000429c40 in linux_resume_one_lwp_throw (info=<optimized out>, signal=0, step=0, lwp=0x31832830) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4463 #5 linux_resume_one_lwp (lwp=0x31832830, step=<optimized out>, signal=<optimized out>, info=<optimized out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4573 The is the case that threads are disappeared when GDB/GDBserver resumes them. We check errno for ESRCH, and don't print error messages, like what we are doing in regsets_store_inferior_registers. gdb/gdbserver: 2016-08-04 Yao Qi <yao.qi@linaro.org> * linux-low.c (regsets_fetch_inferior_registers): Check errno is ESRCH or not.
2016-08-04 11:44:18 +02:00
else if (errno == ESRCH)
{
/* At this point, ESRCH should mean the process is
already gone, in which case we simply ignore attempts
to read its registers. */
}
else
{
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
char s[256];
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
sprintf (s, "ptrace(regsets_fetch_inferior_registers) PID=%d",
pid);
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
perror (s);
}
}
else
{
if (regset->type == GENERAL_REGS)
saw_general_regs = 1;
regset->store_function (regcache, buf);
}
free (buf);
}
if (saw_general_regs)
return 0;
else
return 1;
}
static int
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
regsets_store_inferior_registers (struct regsets_info *regsets_info,
struct regcache *regcache)
{
struct regset_info *regset;
int saw_general_regs = 0;
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
int pid;
Add x86 AVX support to gdbserver. 2010-04-07 H.J. Lu <hongjiu.lu@intel.com> * Makefile.in (clean): Updated. (i386-avx.o): New. (i386-avx.c): Likewise. (i386-avx-linux.o): Likewise. (i386-avx-linux.c): Likewise. (amd64-avx.o): Likewise. (amd64-avx.c): Likewise. (amd64-avx-linux.o): Likewise. (amd64-avx-linux.c): Likewise. * configure.srv (srv_i386_regobj): Add i386-avx.o. (srv_i386_linux_regobj): Add i386-avx-linux.o. (srv_amd64_regobj): Add amd64-avx.o. (srv_amd64_linux_regobj): Add amd64-avx-linux.o. (srv_i386_32bit_xmlfiles): Add i386/32bit-avx.xml. (srv_i386_64bit_xmlfiles): Add i386/64bit-avx.xml. (srv_i386_xmlfiles): Add i386/i386-avx.xml. (srv_amd64_xmlfiles): Add i386/amd64-avx.xml. (srv_i386_linux_xmlfiles): Add i386/i386-avx-linux.xml. (srv_amd64_linux_xmlfiles): Add i386/amd64-avx-linux.xml. * i387-fp.c: Include "i386-xstate.h". (i387_xsave): New. (i387_cache_to_xsave): Likewise. (i387_xsave_to_cache): Likewise. (x86_xcr0): Likewise. * i387-fp.h (i387_cache_to_xsave): Likewise. (i387_xsave_to_cache): Likewise. (x86_xcr0): Likewise. * linux-arm-low.c (target_regsets): Initialize nt_type to 0. * linux-crisv32-low.c (target_regsets): Likewise. * linux-m68k-low.c (target_regsets): Likewise. * linux-mips-low.c (target_regsets): Likewise. * linux-ppc-low.c (target_regsets): Likewise. * linux-s390-low.c (target_regsets): Likewise. * linux-sh-low.c (target_regsets): Likewise. * linux-sparc-low.c (target_regsets): Likewise. * linux-xtensa-low.c (target_regsets): Likewise. * linux-low.c: Include <sys/uio.h>. (regsets_fetch_inferior_registers): Support nt_type. (regsets_store_inferior_registers): Likewise. (linux_process_qsupported): New. (linux_target_ops): Add linux_process_qsupported. * linux-low.h (regset_info): Add nt_type. (linux_target_ops): Add process_qsupported. * linux-x86-low.c: Include "i386-xstate.h", "elf/common.h" and <sys/uio.h>. (init_registers_i386_avx_linux): New. (init_registers_amd64_avx_linux): Likewise. (xmltarget_i386_linux_no_xml): Likewise. (xmltarget_amd64_linux_no_xml): Likewise. (PTRACE_GETREGSET): Likewise. (PTRACE_SETREGSET): Likewise. (x86_fill_xstateregset): Likewise. (x86_store_xstateregset): Likewise. (use_xml): Likewise. (x86_linux_update_xmltarget): Likewise. (x86_linux_process_qsupported): Likewise. (target_regsets): Add NT_X86_XSTATE entry and Initialize nt_type. (x86_arch_setup): Don't call init_registers_amd64_linux nor init_registers_i386_linux here. Call x86_linux_update_xmltarget. (the_low_target): Add x86_linux_process_qsupported. * server.c (handle_query): Call target_process_qsupported. * target.h (target_ops): Add process_qsupported. (target_process_qsupported): New.
2010-04-07 20:49:46 +02:00
struct iovec iov;
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
pid = lwpid_of (current_thread);
for (regset = regsets_info->regsets; regset->size >= 0; regset++)
{
Add x86 AVX support to gdbserver. 2010-04-07 H.J. Lu <hongjiu.lu@intel.com> * Makefile.in (clean): Updated. (i386-avx.o): New. (i386-avx.c): Likewise. (i386-avx-linux.o): Likewise. (i386-avx-linux.c): Likewise. (amd64-avx.o): Likewise. (amd64-avx.c): Likewise. (amd64-avx-linux.o): Likewise. (amd64-avx-linux.c): Likewise. * configure.srv (srv_i386_regobj): Add i386-avx.o. (srv_i386_linux_regobj): Add i386-avx-linux.o. (srv_amd64_regobj): Add amd64-avx.o. (srv_amd64_linux_regobj): Add amd64-avx-linux.o. (srv_i386_32bit_xmlfiles): Add i386/32bit-avx.xml. (srv_i386_64bit_xmlfiles): Add i386/64bit-avx.xml. (srv_i386_xmlfiles): Add i386/i386-avx.xml. (srv_amd64_xmlfiles): Add i386/amd64-avx.xml. (srv_i386_linux_xmlfiles): Add i386/i386-avx-linux.xml. (srv_amd64_linux_xmlfiles): Add i386/amd64-avx-linux.xml. * i387-fp.c: Include "i386-xstate.h". (i387_xsave): New. (i387_cache_to_xsave): Likewise. (i387_xsave_to_cache): Likewise. (x86_xcr0): Likewise. * i387-fp.h (i387_cache_to_xsave): Likewise. (i387_xsave_to_cache): Likewise. (x86_xcr0): Likewise. * linux-arm-low.c (target_regsets): Initialize nt_type to 0. * linux-crisv32-low.c (target_regsets): Likewise. * linux-m68k-low.c (target_regsets): Likewise. * linux-mips-low.c (target_regsets): Likewise. * linux-ppc-low.c (target_regsets): Likewise. * linux-s390-low.c (target_regsets): Likewise. * linux-sh-low.c (target_regsets): Likewise. * linux-sparc-low.c (target_regsets): Likewise. * linux-xtensa-low.c (target_regsets): Likewise. * linux-low.c: Include <sys/uio.h>. (regsets_fetch_inferior_registers): Support nt_type. (regsets_store_inferior_registers): Likewise. (linux_process_qsupported): New. (linux_target_ops): Add linux_process_qsupported. * linux-low.h (regset_info): Add nt_type. (linux_target_ops): Add process_qsupported. * linux-x86-low.c: Include "i386-xstate.h", "elf/common.h" and <sys/uio.h>. (init_registers_i386_avx_linux): New. (init_registers_amd64_avx_linux): Likewise. (xmltarget_i386_linux_no_xml): Likewise. (xmltarget_amd64_linux_no_xml): Likewise. (PTRACE_GETREGSET): Likewise. (PTRACE_SETREGSET): Likewise. (x86_fill_xstateregset): Likewise. (x86_store_xstateregset): Likewise. (use_xml): Likewise. (x86_linux_update_xmltarget): Likewise. (x86_linux_process_qsupported): Likewise. (target_regsets): Add NT_X86_XSTATE entry and Initialize nt_type. (x86_arch_setup): Don't call init_registers_amd64_linux nor init_registers_i386_linux here. Call x86_linux_update_xmltarget. (the_low_target): Add x86_linux_process_qsupported. * server.c (handle_query): Call target_process_qsupported. * target.h (target_ops): Add process_qsupported. (target_process_qsupported): New.
2010-04-07 20:49:46 +02:00
void *buf, *data;
int nt_type, res;
if (regset->size == 0 || regset_disabled (regsets_info, regset)
|| regset->fill_function == NULL)
continue;
buf = xmalloc (regset->size);
/* First fill the buffer with the current register set contents,
in case there are any items in the kernel's regset that are
not in gdbserver's regcache. */
Add x86 AVX support to gdbserver. 2010-04-07 H.J. Lu <hongjiu.lu@intel.com> * Makefile.in (clean): Updated. (i386-avx.o): New. (i386-avx.c): Likewise. (i386-avx-linux.o): Likewise. (i386-avx-linux.c): Likewise. (amd64-avx.o): Likewise. (amd64-avx.c): Likewise. (amd64-avx-linux.o): Likewise. (amd64-avx-linux.c): Likewise. * configure.srv (srv_i386_regobj): Add i386-avx.o. (srv_i386_linux_regobj): Add i386-avx-linux.o. (srv_amd64_regobj): Add amd64-avx.o. (srv_amd64_linux_regobj): Add amd64-avx-linux.o. (srv_i386_32bit_xmlfiles): Add i386/32bit-avx.xml. (srv_i386_64bit_xmlfiles): Add i386/64bit-avx.xml. (srv_i386_xmlfiles): Add i386/i386-avx.xml. (srv_amd64_xmlfiles): Add i386/amd64-avx.xml. (srv_i386_linux_xmlfiles): Add i386/i386-avx-linux.xml. (srv_amd64_linux_xmlfiles): Add i386/amd64-avx-linux.xml. * i387-fp.c: Include "i386-xstate.h". (i387_xsave): New. (i387_cache_to_xsave): Likewise. (i387_xsave_to_cache): Likewise. (x86_xcr0): Likewise. * i387-fp.h (i387_cache_to_xsave): Likewise. (i387_xsave_to_cache): Likewise. (x86_xcr0): Likewise. * linux-arm-low.c (target_regsets): Initialize nt_type to 0. * linux-crisv32-low.c (target_regsets): Likewise. * linux-m68k-low.c (target_regsets): Likewise. * linux-mips-low.c (target_regsets): Likewise. * linux-ppc-low.c (target_regsets): Likewise. * linux-s390-low.c (target_regsets): Likewise. * linux-sh-low.c (target_regsets): Likewise. * linux-sparc-low.c (target_regsets): Likewise. * linux-xtensa-low.c (target_regsets): Likewise. * linux-low.c: Include <sys/uio.h>. (regsets_fetch_inferior_registers): Support nt_type. (regsets_store_inferior_registers): Likewise. (linux_process_qsupported): New. (linux_target_ops): Add linux_process_qsupported. * linux-low.h (regset_info): Add nt_type. (linux_target_ops): Add process_qsupported. * linux-x86-low.c: Include "i386-xstate.h", "elf/common.h" and <sys/uio.h>. (init_registers_i386_avx_linux): New. (init_registers_amd64_avx_linux): Likewise. (xmltarget_i386_linux_no_xml): Likewise. (xmltarget_amd64_linux_no_xml): Likewise. (PTRACE_GETREGSET): Likewise. (PTRACE_SETREGSET): Likewise. (x86_fill_xstateregset): Likewise. (x86_store_xstateregset): Likewise. (use_xml): Likewise. (x86_linux_update_xmltarget): Likewise. (x86_linux_process_qsupported): Likewise. (target_regsets): Add NT_X86_XSTATE entry and Initialize nt_type. (x86_arch_setup): Don't call init_registers_amd64_linux nor init_registers_i386_linux here. Call x86_linux_update_xmltarget. (the_low_target): Add x86_linux_process_qsupported. * server.c (handle_query): Call target_process_qsupported. * target.h (target_ops): Add process_qsupported. (target_process_qsupported): New.
2010-04-07 20:49:46 +02:00
nt_type = regset->nt_type;
if (nt_type)
{
iov.iov_base = buf;
iov.iov_len = regset->size;
data = (void *) &iov;
}
else
data = buf;
#ifndef __sparc__
res = ptrace (regset->get_request, pid,
(PTRACE_TYPE_ARG3) (long) nt_type, data);
#else
res = ptrace (regset->get_request, pid, data, nt_type);
#endif
if (res == 0)
{
/* Then overlay our cached registers on that. */
* regcache.h (struct thread_info): Forward declare. (struct regcache): New. (new_register_cache): Adjust prototype. (get_thread_regcache): Declare. (free_register_cache): Adjust prototype. (registers_to_string, registers_from_string): Ditto. (supply_register, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Ditto. * regcache.c (struct inferior_regcache_data): Delete. (get_regcache): Rename to ... (get_thread_regcache): ... this. Adjust. Switch inferior before fetching registers. (regcache_invalidate_one): Adjust. (regcache_invalidate): Fix prototype. (new_register_cache): Return the new register cache. (free_register_cache): Change prototype. (realloc_register_cache): Adjust. (registers_to_string): Change prototype to take a regcache. Adjust. (registers_from_string): Ditto. (register_data): Ditto. (supply_register): Ditto. (supply_register_by_name): Ditto. (collect_register): Ditto. (collect_register_as_string): Ditto. (collect_register_by_name): Ditto. * server.c (process_serial_event): Adjust. * linux-low.h (regset_fill_func, regset_store_func): Change prototype. (get_pc, set_pc, collect_ptrace_register, supply_ptrace_register): Change prototype. * linux-low.c (get_stop_pc): Adjust. (check_removed_breakpoint): Adjust. (linux_wait_for_event): Adjust. (linux_resume_one_lwp): Adjust. (fetch_register): Add regcache parameter. Adjust. (usr_store_inferior_registers): Ditto. (regsets_fetch_inferior_registers): Ditto. (regsets_store_inferior_registers): Ditto. (linux_fetch_registers, linux_store_registers): Ditto. * i387-fp.c (i387_cache_to_fsave): Change prototype to take a regcache. Adjust. (i387_fsave_to_cache, i387_cache_to_fxsave, i387_fxsave_to_cache): Ditto. * i387-fp.h (i387_cache_to_fsave, i387_fsave_to_cache): Change prototype to take a regcache. (i387_cache_to_fxsave, i387_fxsave_to_cache): Ditto. * remote-utils.c (convert_ascii_to_int, outreg) (prepare_resume_reply): Change prototype to take a regcache. Adjust. * target.h (struct target_ops) <fetch_registers, store_registers>: Change prototype to take a regcache. (fetch_inferior_registers, store_inferior_registers): Change prototype to take a regcache. Adjust. * proc-service.c (ps_lgetregs): Adjust. * linux-x86-low.c (x86_fill_gregset, x86_store_gregset) (x86_fill_fpregset, x86_store_fpregset, x86_fill_fpxregset) (x86_store_fpxregset, x86_get_pc, x86_set_pc): Change prototype to take a regcache. Adjust. * linux-arm-low.c (arm_fill_gregset, arm_store_gregset) (arm_fill_wmmxregset, arm_store_wmmxregset, arm_fill_vfpregset) (arm_store_vfpregset, arm_get_pc, arm_set_pc): (arm_breakpoint_at): Change prototype to take a regcache. Adjust. * linux-cris-low.c (cris_get_pc, cris_set_pc) (cris_cannot_fetch_register): (cris_breakpoint_at): Change prototype to take a regcache. Adjust. * linux-crisv32-low.c (cris_get_pc, cris_set_pc, cris_reinsert_addr, cris_write_data_breakpoint): Change prototype to take a regcache. Adjust. (cris_breakpoint_at, cris_insert_point, cris_remove_point): Adjust. * linux-m32r-low.c (m32r_get_pc, m32r_set_pc): Change prototype to take a regcache. Adjust. * linux-m68k-low.c (m68k_fill_gregset, m68k_store_gregset) (m68k_fill_fpregset, m68k_store_fpregset, m68k_get_pc, (m68k_set_pc): Change prototype to take a regcache. Adjust. * linux-mips-low.c (mips_get_pc): (mips_set_pc): Change prototype to take a regcache. Adjust. (mips_reinsert_addr): Adjust. (mips_collect_register): Change prototype to take a regcache. Adjust. (mips_supply_register): (mips_collect_register_32bit, mips_supply_register_32bit) (mips_fill_gregset, mips_store_gregset, mips_fill_fpregset) (mips_store_fpregset): Ditto. * linux-ppc-low.c (ppc_supply_ptrace_register, ppc_supply_ptrace_register): Ditto. (parse_spufs_run): Adjust. (ppc_get_pc, ppc_set_pc, ppc_fill_gregset, ppc_fill_vsxregset) (ppc_store_vsxregset, ppc_fill_vrregset, ppc_store_vrregset) (ppc_fill_evrregset, ppc_store_evrregset): Change prototype to take a regcache. Adjust. * linux-s390-low.c (s390_collect_ptrace_register) (s390_supply_ptrace_register, s390_fill_gregset, s390_get_pc) (s390_set_pc): Change prototype to take a regcache. Adjust. (s390_arch_setup): Adjust. * linux-sh-low.c (sh_get_pc, sh_breakpoint_at) (sh_fill_gregset): Change prototype to take a regcache. Adjust. * linux-sparc-low.c (sparc_fill_gregset_to_stack) (sparc_fill_gregset, sparc_store_gregset_from_stack) (sparc_store_gregset, sparc_get_pc): Change prototype to take a regcache. Adjust. (sparc_breakpoint_at): Adjust. * linux-xtensa-low.c (xtensa_fill_gregset): (xtensa_store_gregset): (xtensa_fill_xtregset, xtensa_store_xtregset, xtensa_get_pc) (xtensa_set_pc): Change prototype to take a regcache. Adjust. * nto-low.c (nto_fetch_registers, nto_store_registers): Change prototype to take a regcache. Adjust. * win32-arm-low.c (arm_fetch_inferior_register) (arm_store_inferior_register): Change prototype to take a regcache. Adjust. * win32-i386-low.c (i386_fetch_inferior_register) (i386_store_inferior_register): Change prototype to take a regcache. Adjust. * win32-low.c (child_fetch_inferior_registers) (child_store_inferior_registers): Change prototype to take a regcache. Adjust. (win32_wait): Adjust. (win32_fetch_inferior_registers): Change prototype to take a regcache. Adjust. (win32_store_inferior_registers): Adjust. * win32-low.h (struct win32_target_ops) <fetch_inferior_register, store_inferior_register>: Change prototype to take a regcache.
2010-01-20 23:55:38 +01:00
regset->fill_function (regcache, buf);
/* Only now do we write the register set. */
#ifndef __sparc__
res = ptrace (regset->set_request, pid,
(PTRACE_TYPE_ARG3) (long) nt_type, data);
#else
Add x86 AVX support to gdbserver. 2010-04-07 H.J. Lu <hongjiu.lu@intel.com> * Makefile.in (clean): Updated. (i386-avx.o): New. (i386-avx.c): Likewise. (i386-avx-linux.o): Likewise. (i386-avx-linux.c): Likewise. (amd64-avx.o): Likewise. (amd64-avx.c): Likewise. (amd64-avx-linux.o): Likewise. (amd64-avx-linux.c): Likewise. * configure.srv (srv_i386_regobj): Add i386-avx.o. (srv_i386_linux_regobj): Add i386-avx-linux.o. (srv_amd64_regobj): Add amd64-avx.o. (srv_amd64_linux_regobj): Add amd64-avx-linux.o. (srv_i386_32bit_xmlfiles): Add i386/32bit-avx.xml. (srv_i386_64bit_xmlfiles): Add i386/64bit-avx.xml. (srv_i386_xmlfiles): Add i386/i386-avx.xml. (srv_amd64_xmlfiles): Add i386/amd64-avx.xml. (srv_i386_linux_xmlfiles): Add i386/i386-avx-linux.xml. (srv_amd64_linux_xmlfiles): Add i386/amd64-avx-linux.xml. * i387-fp.c: Include "i386-xstate.h". (i387_xsave): New. (i387_cache_to_xsave): Likewise. (i387_xsave_to_cache): Likewise. (x86_xcr0): Likewise. * i387-fp.h (i387_cache_to_xsave): Likewise. (i387_xsave_to_cache): Likewise. (x86_xcr0): Likewise. * linux-arm-low.c (target_regsets): Initialize nt_type to 0. * linux-crisv32-low.c (target_regsets): Likewise. * linux-m68k-low.c (target_regsets): Likewise. * linux-mips-low.c (target_regsets): Likewise. * linux-ppc-low.c (target_regsets): Likewise. * linux-s390-low.c (target_regsets): Likewise. * linux-sh-low.c (target_regsets): Likewise. * linux-sparc-low.c (target_regsets): Likewise. * linux-xtensa-low.c (target_regsets): Likewise. * linux-low.c: Include <sys/uio.h>. (regsets_fetch_inferior_registers): Support nt_type. (regsets_store_inferior_registers): Likewise. (linux_process_qsupported): New. (linux_target_ops): Add linux_process_qsupported. * linux-low.h (regset_info): Add nt_type. (linux_target_ops): Add process_qsupported. * linux-x86-low.c: Include "i386-xstate.h", "elf/common.h" and <sys/uio.h>. (init_registers_i386_avx_linux): New. (init_registers_amd64_avx_linux): Likewise. (xmltarget_i386_linux_no_xml): Likewise. (xmltarget_amd64_linux_no_xml): Likewise. (PTRACE_GETREGSET): Likewise. (PTRACE_SETREGSET): Likewise. (x86_fill_xstateregset): Likewise. (x86_store_xstateregset): Likewise. (use_xml): Likewise. (x86_linux_update_xmltarget): Likewise. (x86_linux_process_qsupported): Likewise. (target_regsets): Add NT_X86_XSTATE entry and Initialize nt_type. (x86_arch_setup): Don't call init_registers_amd64_linux nor init_registers_i386_linux here. Call x86_linux_update_xmltarget. (the_low_target): Add x86_linux_process_qsupported. * server.c (handle_query): Call target_process_qsupported. * target.h (target_ops): Add process_qsupported. (target_process_qsupported): New.
2010-04-07 20:49:46 +02:00
res = ptrace (regset->set_request, pid, data, nt_type);
#endif
}
if (res < 0)
{
if (errno == EIO
|| (errno == EINVAL && regset->type == OPTIONAL_REGS))
{
/* If we get EIO on a regset, or an EINVAL and the regset is
optional, do not try it again for this process mode. */
disable_regset (regsets_info, regset);
}
else if (errno == ESRCH)
{
/* At this point, ESRCH should mean the process is
already gone, in which case we simply ignore attempts
to change its registers. See also the related
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
comment in resume_one_lwp. */
free (buf);
return 0;
}
else
{
2002-04-09 Daniel Jacobowitz <drow@mvista.com> * gdbserver/inferiors.c: New file. * gdbserver/target.c: New file. * gdbserver/target.h: New file. * gdbserver/Makefile.in: Add target.o and inferiors.o. Update dependencies. * gdbserver/linux-low.c (inferior_pid): New static variable, moved from server.c. (linux_create_inferior): Renamed from create_inferior. Call add_inferior. Return 0 on success instead of a PID. (linux_attach): Renamed from myattach. (linux_kill): Renamed from kill_inferior. Call clear_inferiors (). (linux_thread_alive): Renamed from mythread_alive. (linux_wait): Renamed from mywait. Call clear_inferiors () if the child dies. (linux_resume): Renamed from myresume. Add missing ``return 0''. (regsets_store_inferior_registers): Correct error message. Add missing ``return 0''. (linux_fetch_registers): Renamed from fetch_inferior_registers. (linux_store_registers): Renamed from store_inferior_registers. (linux_read_memory): Renamed from read_inferior_memory. (linux_write_memory): Renamed from write_inferior_memory. (linux_target_ops): New structure. (initialize_low): Call set_target_ops (). * gdbserver/remote-utils.c (unhexify): New function. (hexify): New function. (input_interrupt): Send signals to ``signal_pid''. * gdbserver/server.c (inferior_pid): Remove. (start_inferior): Update create_inferior call. (attach_inferior): Call add_inferior. (handle_query): New function. (main): Call handle_query for `q' packets. * gdbserver/server.h: Include "target.h". Remove obsolete prototypes. Add prototypes for "inferiors.c", "target.c", hexify, and unhexify.
2002-04-09 23:17:45 +02:00
perror ("Warning: ptrace(regsets_store_inferior_registers)");
}
}
else if (regset->type == GENERAL_REGS)
saw_general_regs = 1;
free (buf);
}
if (saw_general_regs)
return 0;
else
return 1;
}
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
#else /* !HAVE_LINUX_REGSETS */
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
#define use_linux_regsets 0
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
#define regsets_fetch_inferior_registers(regsets_info, regcache) 1
#define regsets_store_inferior_registers(regsets_info, regcache) 1
#endif
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
/* Return 1 if register REGNO is supported by one of the regset ptrace
calls or 0 if it has to be transferred individually. */
static int
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
linux_register_in_regsets (const struct regs_info *regs_info, int regno)
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
{
unsigned char mask = 1 << (regno % 8);
size_t index = regno / 8;
return (use_linux_regsets
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
&& (regs_info->regset_bitmap == NULL
|| (regs_info->regset_bitmap[index] & mask) != 0));
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
}
#ifdef HAVE_LINUX_USRREGS
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
static int
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
register_addr (const struct usrregs_info *usrregs, int regnum)
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
{
int addr;
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
if (regnum < 0 || regnum >= usrregs->num_regs)
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
error ("Invalid register number %d.", regnum);
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
addr = usrregs->regmap[regnum];
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
return addr;
}
gdbserver/linux-low: turn 'cannot_{fetch/store}_register' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'cannot_fetch_register' and 'cannot_store_register' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the low target ops. (class linux_process_target) <fetch_register> <store_register> <usr_fetch_inferior_registers> <usr_store_inferior_registers> <low_cannot_fetch_register> <low_cannot_fetch_register> Declare. * linux-low.cc (fetch_register): Turn into... (linux_process_target::fetch_register): ...this. (store_register): Turn into ... (linux_process_target::store_register): ...this. (usr_fetch_inferior_registers): Turn into... (linux_process_target::usr_fetch_inferior_registers): ...this. (usr_store_inferior_registers): Turn into... (linux_process_target::usr_store_inferior_registers): ...this. * linux-x86-low.cc (class x86_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (x86_cannot_store_register): Turn into... (x86_target::low_cannot_store_register): ...this. (x86_cannot_fetch_register): Turn into... (x86_target::low_cannot_fetch_register): ...this. (the_low_target): Remove the target op fields. * linux-aarch64-low.cc (class aarch64_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (aarch64_target::low_cannot_fetch_register) (aarch64_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (arm_cannot_fetch_register): Turn into... (arm_target::low_cannot_fetch_register): ...this. (arm_cannot_store_register): Turn into... (arm_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (bfin_cannot_fetch_register): Turn into... (bfin_target::low_cannot_fetch_register): ...this. (bfin_cannot_store_register): Turn into... (bfin_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (cris_cannot_fetch_register): Turn into... (cris_target::low_cannot_fetch_register): ...this. (cris_cannot_store_register): Turn into... (cris_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (crisv32_target::low_cannot_fetch_register) (crisv32_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-ia64-low.cc (class ia64_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (ia64_cannot_fetch_register): Turn into... (ia64_target::low_cannot_fetch_register): ...this. (ia64_cannot_store_register): Turn into... (ia64_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (m32r_cannot_fetch_register): Turn into... (m32r_target::low_cannot_fetch_register): ...this. (m32r_cannot_store_register): Turn into... (m32r_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (m68k_cannot_fetch_register): Turn into... (m68k_target::low_cannot_fetch_register): ...this. (m68k_cannot_store_register): Turn into... (m68k_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (mips_cannot_fetch_register): Turn into... (mips_target::low_cannot_fetch_register): ...this. (mips_cannot_store_register): Turn into... (mips_target::low_cannot_store_register): ...this. (get_usrregs_info): Inline at the call sites in low_cannot_fetch_register and low_cannot_store_register, and remove. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (nios2_cannot_fetch_register): Turn into... (nios2_target::low_cannot_fetch_register): ...this. (nios2_cannot_store_register): Turn into... (nios2_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (ppc_cannot_fetch_register): Turn into... (ppc_target::low_cannot_fetch_register): ...this. (ppc_cannot_store_register): Turn into... (ppc_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (riscv_target::low_cannot_fetch_register) (riscv_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (s390_cannot_fetch_register): Turn into... (s390_target::low_cannot_fetch_register): ...this. (s390_cannot_store_register): Turn into... (s390_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (sh_cannot_fetch_register): Turn into... (sh_target::low_cannot_fetch_register): ...this. (sh_cannot_store_register): Turn into... (sh_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (sparc_cannot_fetch_register): Turn into... (sparc_target::low_cannot_fetch_register): ...this. (sparc_cannot_store_register): Turn into... (sparc_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (tic6x_cannot_fetch_register): Turn into... (tic6x_target::low_cannot_fetch_register): ...this. (tic6x_cannot_store_register): Turn into... (tic6x_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (tile_cannot_fetch_register): Turn into... (tile_target::low_cannot_fetch_register): ...this. (tile_cannot_store_register): Turn into... (tile_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (xtensa_target::low_cannot_fetch_register) (xtensa_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
void
linux_process_target::fetch_register (const usrregs_info *usrregs,
regcache *regcache, int regno)
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
{
CORE_ADDR regaddr;
int i, size;
char *buf;
int pid;
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
if (regno >= usrregs->num_regs)
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
return;
gdbserver/linux-low: turn 'cannot_{fetch/store}_register' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'cannot_fetch_register' and 'cannot_store_register' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the low target ops. (class linux_process_target) <fetch_register> <store_register> <usr_fetch_inferior_registers> <usr_store_inferior_registers> <low_cannot_fetch_register> <low_cannot_fetch_register> Declare. * linux-low.cc (fetch_register): Turn into... (linux_process_target::fetch_register): ...this. (store_register): Turn into ... (linux_process_target::store_register): ...this. (usr_fetch_inferior_registers): Turn into... (linux_process_target::usr_fetch_inferior_registers): ...this. (usr_store_inferior_registers): Turn into... (linux_process_target::usr_store_inferior_registers): ...this. * linux-x86-low.cc (class x86_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (x86_cannot_store_register): Turn into... (x86_target::low_cannot_store_register): ...this. (x86_cannot_fetch_register): Turn into... (x86_target::low_cannot_fetch_register): ...this. (the_low_target): Remove the target op fields. * linux-aarch64-low.cc (class aarch64_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (aarch64_target::low_cannot_fetch_register) (aarch64_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (arm_cannot_fetch_register): Turn into... (arm_target::low_cannot_fetch_register): ...this. (arm_cannot_store_register): Turn into... (arm_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (bfin_cannot_fetch_register): Turn into... (bfin_target::low_cannot_fetch_register): ...this. (bfin_cannot_store_register): Turn into... (bfin_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (cris_cannot_fetch_register): Turn into... (cris_target::low_cannot_fetch_register): ...this. (cris_cannot_store_register): Turn into... (cris_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (crisv32_target::low_cannot_fetch_register) (crisv32_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-ia64-low.cc (class ia64_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (ia64_cannot_fetch_register): Turn into... (ia64_target::low_cannot_fetch_register): ...this. (ia64_cannot_store_register): Turn into... (ia64_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (m32r_cannot_fetch_register): Turn into... (m32r_target::low_cannot_fetch_register): ...this. (m32r_cannot_store_register): Turn into... (m32r_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (m68k_cannot_fetch_register): Turn into... (m68k_target::low_cannot_fetch_register): ...this. (m68k_cannot_store_register): Turn into... (m68k_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (mips_cannot_fetch_register): Turn into... (mips_target::low_cannot_fetch_register): ...this. (mips_cannot_store_register): Turn into... (mips_target::low_cannot_store_register): ...this. (get_usrregs_info): Inline at the call sites in low_cannot_fetch_register and low_cannot_store_register, and remove. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (nios2_cannot_fetch_register): Turn into... (nios2_target::low_cannot_fetch_register): ...this. (nios2_cannot_store_register): Turn into... (nios2_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (ppc_cannot_fetch_register): Turn into... (ppc_target::low_cannot_fetch_register): ...this. (ppc_cannot_store_register): Turn into... (ppc_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (riscv_target::low_cannot_fetch_register) (riscv_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (s390_cannot_fetch_register): Turn into... (s390_target::low_cannot_fetch_register): ...this. (s390_cannot_store_register): Turn into... (s390_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (sh_cannot_fetch_register): Turn into... (sh_target::low_cannot_fetch_register): ...this. (sh_cannot_store_register): Turn into... (sh_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (sparc_cannot_fetch_register): Turn into... (sparc_target::low_cannot_fetch_register): ...this. (sparc_cannot_store_register): Turn into... (sparc_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (tic6x_cannot_fetch_register): Turn into... (tic6x_target::low_cannot_fetch_register): ...this. (tic6x_cannot_store_register): Turn into... (tic6x_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (tile_cannot_fetch_register): Turn into... (tile_target::low_cannot_fetch_register): ...this. (tile_cannot_store_register): Turn into... (tile_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (xtensa_target::low_cannot_fetch_register) (xtensa_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
if (low_cannot_fetch_register (regno))
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
return;
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
regaddr = register_addr (usrregs, regno);
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
if (regaddr == -1)
return;
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
size = ((register_size (regcache->tdesc, regno)
+ sizeof (PTRACE_XFER_TYPE) - 1)
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
& -sizeof (PTRACE_XFER_TYPE));
Add casts to memory allocation related calls Most allocation functions (if not all) return a void* pointing to the allocated memory. In C++, we need to add an explicit cast when assigning the result to a pointer to another type (which is the case more often than not). The content of this patch is taken from Pedro's branch, from commit "(mostly) auto-generated patch to insert casts needed for C++". I validated that the changes make sense and manually reflowed the code to make it respect the coding style. I also found multiple places where I could use XNEW/XNEWVEC/XRESIZEVEC/etc. Thanks a lot to whoever did that automated script to insert casts, doing it completely by hand would have taken a ridiculous amount of time. Only files built on x86 with --enable-targets=all are modified. This means that all other -nat.c files are untouched and will have to be dealt with later by using appropiate compilers. Or maybe we can try to build them with a regular g++ just to know where to add casts, I don't know. I built-tested this with --enable-targets=all and reg-tested. Here's the changelog entry, which was not too bad to make despite the size, thanks to David Malcom's script. I fixed some bits by hand, but there might be some wrong parts left (hopefully not). gdb/ChangeLog: * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Add cast to allocation result assignment. * ada-exp.y (write_object_renaming): Likewise. (write_ambiguous_var): Likewise. (ada_nget_field_index): Likewise. (write_var_or_type): Likewise. * ada-lang.c (ada_decode_symbol): Likewise. (ada_value_assign): Likewise. (value_pointer): Likewise. (cache_symbol): Likewise. (add_nonlocal_symbols): Likewise. (ada_name_for_lookup): Likewise. (symbol_completion_add): Likewise. (ada_to_fixed_type_1): Likewise. (ada_get_next_arg): Likewise. (defns_collected): Likewise. * ada-lex.l (processId): Likewise. (processString): Likewise. * ada-tasks.c (read_known_tasks_array): Likewise. (read_known_tasks_list): Likewise. * ada-typeprint.c (decoded_type_name): Likewise. * addrmap.c (addrmap_mutable_create_fixed): Likewise. * amd64-tdep.c (amd64_push_arguments): Likewise. (amd64_displaced_step_copy_insn): Likewise. (amd64_classify_insn_at): Likewise. (amd64_relocate_instruction): Likewise. * amd64obsd-tdep.c (amd64obsd_sigtramp_p): Likewise. * arch-utils.c (simple_displaced_step_copy_insn): Likewise. (initialize_current_architecture): Likewise. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * arm-symbian-tdep.c (arm_symbian_osabi_sniffer): Likewise. * arm-tdep.c (arm_exidx_new_objfile): Likewise. (arm_push_dummy_call): Likewise. (extend_buffer_earlier): Likewise. (arm_adjust_breakpoint_address): Likewise. (arm_skip_stub): Likewise. * auto-load.c (filename_is_in_pattern): Likewise. (maybe_add_script_file): Likewise. (maybe_add_script_text): Likewise. (auto_load_objfile_script_1): Likewise. * auxv.c (ld_so_xfer_auxv): Likewise. * ax-general.c (new_agent_expr): Likewise. (grow_expr): Likewise. (ax_reg_mask): Likewise. * bcache.c (bcache_full): Likewise. * breakpoint.c (program_breakpoint_here_p): Likewise. * btrace.c (parse_xml_raw): Likewise. * build-id.c (build_id_to_debug_bfd): Likewise. * buildsym.c (end_symtab_with_blockvector): Likewise. * c-exp.y (string_exp): Likewise. (qualified_name): Likewise. (write_destructor_name): Likewise. (operator_stoken): Likewise. (parse_number): Likewise. (scan_macro_expansion): Likewise. (yylex): Likewise. (c_print_token): Likewise. * c-lang.c (c_get_string): Likewise. (emit_numeric_character): Likewise. * charset.c (wchar_iterate): Likewise. * cli/cli-cmds.c (complete_command): Likewise. (make_command): Likewise. * cli/cli-dump.c (restore_section_callback): Likewise. (restore_binary_file): Likewise. * cli/cli-interp.c (cli_interpreter_exec): Likewise. * cli/cli-script.c (execute_control_command): Likewise. * cli/cli-setshow.c (do_set_command): Likewise. * coff-pe-read.c (add_pe_forwarded_sym): Likewise. (read_pe_exported_syms): Likewise. * coffread.c (coff_read_struct_type): Likewise. (coff_read_enum_type): Likewise. * common/btrace-common.c (btrace_data_append): Likewise. * common/buffer.c (buffer_grow): Likewise. * common/filestuff.c (gdb_fopen_cloexec): Likewise. * common/format.c (parse_format_string): Likewise. * common/gdb_vecs.c (delim_string_to_char_ptr_vec_append): Likewise. * common/xml-utils.c (xml_escape_text): Likewise. * compile/compile-object-load.c (copy_sections): Likewise. (compile_object_load): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * completer.c (filename_completer): Likewise. * corefile.c (read_memory_typed_address): Likewise. (write_memory_unsigned_integer): Likewise. (write_memory_signed_integer): Likewise. (complete_set_gnutarget): Likewise. * corelow.c (get_core_register_section): Likewise. * cp-name-parser.y (d_grab): Likewise. (allocate_info): Likewise. (cp_new_demangle_parse_info): Likewise. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Likewise. (cp_lookup_symbol_in_namespace): Likewise. (lookup_namespace_scope): Likewise. (find_symbol_in_baseclass): Likewise. (cp_lookup_nested_symbol): Likewise. (cp_lookup_transparent_type_loop): Likewise. * cp-support.c (copy_string_to_obstack): Likewise. (make_symbol_overload_list): Likewise. (make_symbol_overload_list_namespace): Likewise. (make_symbol_overload_list_adl_namespace): Likewise. (first_component_command): Likewise. * cp-valprint.c (cp_print_value): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * d-exp.y (StringExp): Likewise. * d-namespace.c (d_lookup_symbol_in_module): Likewise. (lookup_module_scope): Likewise. (find_symbol_in_baseclass): Likewise. (d_lookup_nested_symbol): Likewise. * dbxread.c (find_stab_function_addr): Likewise. (read_dbx_symtab): Likewise. (dbx_end_psymtab): Likewise. (cp_set_block_scope): Likewise. * dcache.c (dcache_alloc): Likewise. * demangle.c (_initialize_demangler): Likewise. * dicos-tdep.c (dicos_load_module_p): Likewise. * dictionary.c (dict_create_hashed_expandable): Likewise. (dict_create_linear_expandable): Likewise. (expand_hashtable): Likewise. (add_symbol_linear_expandable): Likewise. * dwarf2-frame.c (add_cie): Likewise. (add_fde): Likewise. (dwarf2_build_frame_info): Likewise. * dwarf2expr.c (dwarf_expr_grow_stack): Likewise. (dwarf_expr_fetch_address): Likewise. (add_piece): Likewise. (execute_stack_op): Likewise. * dwarf2loc.c (chain_candidate): Likewise. (dwarf_entry_parameter_to_value): Likewise. (read_pieced_value): Likewise. (write_pieced_value): Likewise. * dwarf2read.c (dwarf2_read_section): Likewise. (add_type_unit): Likewise. (read_comp_units_from_section): Likewise. (fixup_go_packaging): Likewise. (dwarf2_compute_name): Likewise. (dwarf2_physname): Likewise. (create_dwo_unit_in_dwp_v1): Likewise. (create_dwo_unit_in_dwp_v2): Likewise. (read_func_scope): Likewise. (read_call_site_scope): Likewise. (dwarf2_attach_fields_to_type): Likewise. (process_structure_scope): Likewise. (mark_common_block_symbol_computed): Likewise. (read_common_block): Likewise. (abbrev_table_read_table): Likewise. (guess_partial_die_structure_name): Likewise. (fixup_partial_die): Likewise. (add_file_name): Likewise. (dwarf2_const_value_data): Likewise. (dwarf2_const_value_attr): Likewise. (build_error_marker_type): Likewise. (guess_full_die_structure_name): Likewise. (anonymous_struct_prefix): Likewise. (typename_concat): Likewise. (dwarf2_canonicalize_name): Likewise. (dwarf2_name): Likewise. (write_constant_as_bytes): Likewise. (dwarf2_fetch_constant_bytes): Likewise. (copy_string): Likewise. (parse_macro_definition): Likewise. * elfread.c (elf_symfile_segments): Likewise. (elf_rel_plt_read): Likewise. (elf_gnu_ifunc_resolve_by_cache): Likewise. (elf_gnu_ifunc_resolve_by_got): Likewise. (elf_read_minimal_symbols): Likewise. (elf_gnu_ifunc_record_cache): Likewise. * event-top.c (top_level_prompt): Likewise. (command_line_handler): Likewise. * exec.c (resize_section_table): Likewise. * expprint.c (print_subexp_standard): Likewise. * fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise. * findcmd.c (parse_find_args): Likewise. * findvar.c (address_from_register): Likewise. * frame.c (get_prev_frame_always): Likewise. * gdb_bfd.c (gdb_bfd_ref): Likewise. (get_section_descriptor): Likewise. * gdb_obstack.c (obconcat): Likewise. (obstack_strdup): Likewise. * gdbtypes.c (lookup_function_type_with_arguments): Likewise. (create_set_type): Likewise. (lookup_unsigned_typename): Likewise. (lookup_signed_typename): Likewise. (resolve_dynamic_union): Likewise. (resolve_dynamic_struct): Likewise. (add_dyn_prop): Likewise. (copy_dynamic_prop_list): Likewise. (arch_flags_type): Likewise. (append_composite_type_field_raw): Likewise. * gdbtypes.h (INIT_FUNC_SPECIFIC): Likewise. * gnu-v3-abi.c (gnuv3_rtti_type): Likewise. * go-exp.y (string_exp): Likewise. * go-lang.c (go_demangle): Likewise. * guile/guile.c (compute_scheme_string): Likewise. * guile/scm-cmd.c (gdbscm_parse_command_name): Likewise. (gdbscm_canonicalize_command_name): Likewise. * guile/scm-ports.c (ioscm_init_stdio_buffers): Likewise. (ioscm_init_memory_port): Likewise. (ioscm_reinit_memory_port): Likewise. * guile/scm-utils.c (gdbscm_gc_xstrdup): Likewise. (gdbscm_gc_dup_argv): Likewise. * h8300-tdep.c (h8300_push_dummy_call): Likewise. * hppa-tdep.c (internalize_unwinds): Likewise. (read_unwind_info): Likewise. * i386-cygwin-tdep.c (core_process_module_section): Likewise. (windows_core_xfer_shared_libraries): Likewise. * i386-tdep.c (i386_displaced_step_copy_insn): Likewise. (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * i386obsd-tdep.c (i386obsd_sigtramp_p): Likewise. * inf-child.c (inf_child_fileio_readlink): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_store_register): Likewise. * infrun.c (follow_exec): Likewise. (displaced_step_prepare_throw): Likewise. (save_stop_context): Likewise. (save_infcall_suspend_state): Likewise. * jit.c (jit_read_descriptor): Likewise. (jit_read_code_entry): Likewise. (jit_symtab_line_mapping_add_impl): Likewise. (finalize_symtab): Likewise. (jit_unwind_reg_get_impl): Likewise. * jv-exp.y (QualifiedName): Likewise. * jv-lang.c (get_java_utf8_name): Likewise. (type_from_class): Likewise. (java_demangle_type_signature): Likewise. (java_class_name_from_physname): Likewise. * jv-typeprint.c (java_type_print_base): Likewise. * jv-valprint.c (java_value_print): Likewise. * language.c (add_language): Likewise. * linespec.c (add_sal_to_sals_basic): Likewise. (add_sal_to_sals): Likewise. (decode_objc): Likewise. (find_linespec_symbols): Likewise. * linux-fork.c (fork_save_infrun_state): Likewise. * linux-nat.c (linux_nat_detach): Likewise. (linux_nat_fileio_readlink): Likewise. * linux-record.c (record_linux_sockaddr): Likewise. (record_linux_msghdr): Likewise. (Do): Likewise. * linux-tdep.c (linux_core_info_proc_mappings): Likewise. (linux_collect_regset_section_cb): Likewise. (linux_get_siginfo_data): Likewise. * linux-thread-db.c (try_thread_db_load_from_pdir_1): Likewise. (try_thread_db_load_from_dir): Likewise. (thread_db_load_search): Likewise. (info_auto_load_libthread_db): Likewise. * m32c-tdep.c (m32c_m16c_address_to_pointer): Likewise. (m32c_m16c_pointer_to_address): Likewise. * m68hc11-tdep.c (m68hc11_pseudo_register_write): Likewise. * m68k-tdep.c (m68k_get_longjmp_target): Likewise. * machoread.c (macho_check_dsym): Likewise. * macroexp.c (resize_buffer): Likewise. (gather_arguments): Likewise. (maybe_expand): Likewise. * macrotab.c (new_macro_key): Likewise. (new_source_file): Likewise. (new_macro_definition): Likewise. * mdebugread.c (parse_symbol): Likewise. (parse_type): Likewise. (parse_partial_symbols): Likewise. (psymtab_to_symtab_1): Likewise. * mem-break.c (default_memory_insert_breakpoint): Likewise. * mi/mi-cmd-break.c (mi_argv_to_format): Likewise. * mi/mi-main.c (mi_cmd_data_read_memory): Likewise. (mi_cmd_data_read_memory_bytes): Likewise. (mi_cmd_data_write_memory_bytes): Likewise. (mi_cmd_trace_frame_collected): Likewise. * mi/mi-parse.c (mi_parse_argv): Likewise. (mi_parse): Likewise. * minidebug.c (lzma_open): Likewise. (lzma_pread): Likewise. * mips-tdep.c (mips_read_fp_register_single): Likewise. (mips_print_fp_register): Likewise. * mipsnbsd-tdep.c (mipsnbsd_get_longjmp_target): Likewise. * mipsread.c (read_alphacoff_dynamic_symtab): Likewise. * mt-tdep.c (mt_register_name): Likewise. (mt_registers_info): Likewise. (mt_push_dummy_call): Likewise. * namespace.c (add_using_directive): Likewise. * nat/linux-btrace.c (perf_event_read): Likewise. (linux_enable_bts): Likewise. * nat/linux-osdata.c (linux_common_core_of_thread): Likewise. * nat/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Likewise. * nto-tdep.c (nto_find_and_open_solib): Likewise. (nto_parse_redirection): Likewise. * objc-lang.c (objc_demangle): Likewise. (find_methods): Likewise. * objfiles.c (get_objfile_bfd_data): Likewise. (set_objfile_main_name): Likewise. (allocate_objfile): Likewise. (objfile_relocate): Likewise. (update_section_map): Likewise. * osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Likewise. * p-exp.y (exp): Likewise. (yylex): Likewise. * p-valprint.c (pascal_object_print_value): Likewise. * parse.c (initialize_expout): Likewise. (mark_completion_tag): Likewise. (copy_name): Likewise. (parse_float): Likewise. (type_stack_reserve): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. (ppu2spu_prev_register): Likewise. * ppc-ravenscar-thread.c (supply_register_at_address): Likewise. * printcmd.c (printf_wide_c_string): Likewise. (printf_pointer): Likewise. * probe.c (parse_probes): Likewise. * python/py-cmd.c (gdbpy_parse_command_name): Likewise. (cmdpy_init): Likewise. * python/py-gdb-readline.c (gdbpy_readline_wrapper): Likewise. * python/py-symtab.c (set_sal): Likewise. * python/py-unwind.c (pyuw_sniffer): Likewise. * python/python.c (python_interactive_command): Likewise. (compute_python_string): Likewise. * ravenscar-thread.c (get_running_thread_id): Likewise. * record-full.c (record_full_exec_insn): Likewise. (record_full_core_open_1): Likewise. * regcache.c (regcache_raw_read_signed): Likewise. (regcache_raw_read_unsigned): Likewise. (regcache_cooked_read_signed): Likewise. (regcache_cooked_read_unsigned): Likewise. * remote-fileio.c (remote_fileio_func_open): Likewise. (remote_fileio_func_rename): Likewise. (remote_fileio_func_unlink): Likewise. (remote_fileio_func_stat): Likewise. (remote_fileio_func_system): Likewise. * remote-mips.c (mips_xfer_memory): Likewise. (mips_load_srec): Likewise. (pmon_end_download): Likewise. * remote.c (new_remote_state): Likewise. (map_regcache_remote_table): Likewise. (remote_register_number_and_offset): Likewise. (init_remote_state): Likewise. (get_memory_packet_size): Likewise. (remote_pass_signals): Likewise. (remote_program_signals): Likewise. (remote_start_remote): Likewise. (remote_check_symbols): Likewise. (remote_query_supported): Likewise. (extended_remote_attach): Likewise. (process_g_packet): Likewise. (store_registers_using_G): Likewise. (putpkt_binary): Likewise. (read_frame): Likewise. (compare_sections_command): Likewise. (remote_hostio_pread): Likewise. (remote_hostio_readlink): Likewise. (remote_file_put): Likewise. (remote_file_get): Likewise. (remote_pid_to_exec_file): Likewise. (_initialize_remote): Likewise. * rs6000-aix-tdep.c (rs6000_aix_ld_info_to_xml): Likewise. (rs6000_aix_core_xfer_shared_libraries_aix): Likewise. * rs6000-tdep.c (ppc_displaced_step_copy_insn): Likewise. (bfd_uses_spe_extensions): Likewise. * s390-linux-tdep.c (s390_displaced_step_copy_insn): Likewise. * score-tdep.c (score7_malloc_and_get_memblock): Likewise. * solib-dsbt.c (decode_loadmap): Likewise. (fetch_loadmap): Likewise. (scan_dyntag): Likewise. (enable_break): Likewise. (dsbt_relocate_main_executable): Likewise. * solib-frv.c (fetch_loadmap): Likewise. (enable_break2): Likewise. (frv_relocate_main_executable): Likewise. * solib-spu.c (spu_relocate_main_executable): Likewise. (spu_bfd_open): Likewise. * solib-svr4.c (lm_info_read): Likewise. (read_program_header): Likewise. (find_program_interpreter): Likewise. (scan_dyntag): Likewise. (elf_locate_base): Likewise. (open_symbol_file_object): Likewise. (read_program_headers_from_bfd): Likewise. (svr4_relocate_main_executable): Likewise. * solib-target.c (solib_target_relocate_section_addresses): Likewise. * solib.c (solib_find_1): Likewise. (exec_file_find): Likewise. (solib_find): Likewise. * source.c (openp): Likewise. (print_source_lines_base): Likewise. (forward_search_command): Likewise. * sparc-ravenscar-thread.c (supply_register_at_address): Likewise. * spu-tdep.c (spu2ppu_prev_register): Likewise. (spu_get_overlay_table): Likewise. * stabsread.c (patch_block_stabs): Likewise. (define_symbol): Likewise. (again:): Likewise. (read_member_functions): Likewise. (read_one_struct_field): Likewise. (read_enum_type): Likewise. (common_block_start): Likewise. * stack.c (read_frame_arg): Likewise. (backtrace_command): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. * symfile.c (syms_from_objfile_1): Likewise. (find_separate_debug_file): Likewise. (load_command): Likewise. (load_progress): Likewise. (load_section_callback): Likewise. (reread_symbols): Likewise. (add_filename_language): Likewise. (allocate_compunit_symtab): Likewise. (read_target_long_array): Likewise. (simple_read_overlay_table): Likewise. * symtab.c (symbol_set_names): Likewise. (resize_symbol_cache): Likewise. (rbreak_command): Likewise. (completion_list_add_name): Likewise. (completion_list_objc_symbol): Likewise. (add_filename_to_list): Likewise. * target-descriptions.c (maint_print_c_tdesc_cmd): Likewise. * target-memory.c (target_write_memory_blocks): Likewise. * target.c (target_read_string): Likewise. (read_whatever_is_readable): Likewise. (target_read_alloc_1): Likewise. (simple_search_memory): Likewise. (target_fileio_read_alloc_1): Likewise. * tilegx-tdep.c (tilegx_push_dummy_call): Likewise. * top.c (command_line_input): Likewise. * tracefile-tfile.c (tfile_fetch_registers): Likewise. * tracefile.c (tracefile_fetch_registers): Likewise. * tracepoint.c (add_memrange): Likewise. (init_collection_list): Likewise. (add_aexpr): Likewise. (trace_dump_actions): Likewise. (parse_trace_status): Likewise. (parse_tracepoint_definition): Likewise. (parse_tsv_definition): Likewise. (parse_static_tracepoint_marker_definition): Likewise. * tui/tui-file.c (tui_sfileopen): Likewise. (tui_file_adjust_strbuf): Likewise. * tui/tui-io.c (tui_expand_tabs): Likewise. * tui/tui-source.c (tui_set_source_content): Likewise. * typeprint.c (find_global_typedef): Likewise. * ui-file.c (do_ui_file_xstrdup): Likewise. (ui_file_obsavestring): Likewise. (mem_file_write): Likewise. * utils.c (make_hex_string): Likewise. (get_regcomp_error): Likewise. (puts_filtered_tabular): Likewise. (gdb_realpath_keepfile): Likewise. (ldirname): Likewise. (gdb_bfd_errmsg): Likewise. (substitute_path_component): Likewise. * valops.c (search_struct_method): Likewise. (find_oload_champ_namespace_loop): Likewise. * valprint.c (print_decimal_chars): Likewise. (read_string): Likewise. (generic_emit_char): Likewise. * varobj.c (varobj_delete): Likewise. (varobj_value_get_print_value): Likewise. * vaxobsd-tdep.c (vaxobsd_sigtramp_sniffer): Likewise. * windows-tdep.c (display_one_tib): Likewise. * xcoffread.c (read_xcoff_symtab): Likewise. (process_xcoff_symbol): Likewise. (swap_sym): Likewise. (scan_xcoff_symtab): Likewise. (xcoff_initial_scan): Likewise. * xml-support.c (gdb_xml_end_element): Likewise. (xml_process_xincludes): Likewise. (xml_fetch_content_from_file): Likewise. * xml-syscall.c (xml_list_of_syscalls): Likewise. * xstormy16-tdep.c (xstormy16_push_dummy_call): Likewise. gdb/gdbserver/ChangeLog: * ax.c (gdb_parse_agent_expr): Add cast to allocation result assignment. (gdb_unparse_agent_expr): Likewise. * hostio.c (require_data): Likewise. (handle_pread): Likewise. * linux-low.c (disable_regset): Likewise. (fetch_register): Likewise. (store_register): Likewise. (get_dynamic): Likewise. (linux_qxfer_libraries_svr4): Likewise. * mem-break.c (delete_fast_tracepoint_jump): Likewise. (set_fast_tracepoint_jump): Likewise. (uninsert_fast_tracepoint_jumps_at): Likewise. (reinsert_fast_tracepoint_jumps_at): Likewise. (validate_inserted_breakpoint): Likewise. (clone_agent_expr): Likewise. * regcache.c (init_register_cache): Likewise. * remote-utils.c (putpkt_binary_1): Likewise. (decode_M_packet): Likewise. (decode_X_packet): Likewise. (look_up_one_symbol): Likewise. (relocate_instruction): Likewise. (monitor_output): Likewise. * server.c (handle_search_memory): Likewise. (handle_qxfer_exec_file): Likewise. (handle_qxfer_libraries): Likewise. (handle_qxfer): Likewise. (handle_query): Likewise. (handle_v_cont): Likewise. (handle_v_run): Likewise. (captured_main): Likewise. * target.c (write_inferior_memory): Likewise. * thread-db.c (try_thread_db_load_from_dir): Likewise. * tracepoint.c (init_trace_buffer): Likewise. (add_tracepoint_action): Likewise. (add_traceframe): Likewise. (add_traceframe_block): Likewise. (cmd_qtdpsrc): Likewise. (cmd_qtdv): Likewise. (cmd_qtstatus): Likewise. (response_source): Likewise. (response_tsv): Likewise. (cmd_qtnotes): Likewise. (gdb_collect): Likewise. (initialize_tracepoint): Likewise.
2015-09-25 20:08:06 +02:00
buf = (char *) alloca (size);
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
pid = lwpid_of (current_thread);
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
for (i = 0; i < size; i += sizeof (PTRACE_XFER_TYPE))
{
errno = 0;
*(PTRACE_XFER_TYPE *) (buf + i) =
ptrace (PTRACE_PEEKUSER, pid,
/* Coerce to a uintptr_t first to avoid potential gcc warning
of coercing an 8 byte integer to a 4 byte pointer. */
(PTRACE_TYPE_ARG3) (uintptr_t) regaddr, (PTRACE_TYPE_ARG4) 0);
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
regaddr += sizeof (PTRACE_XFER_TYPE);
if (errno != 0)
{
/* Mark register REGNO unavailable. */
supply_register (regcache, regno, NULL);
return;
}
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
}
gdbserver/linux-low: turn '{collect, supply}_ptrace_register' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'collect_ptrace_register' and 'supply_ptrace_register' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <low_collect_ptrace_register> <low_store_ptrace_register>: Declare. * linux-low.cc (linux_process_target::low_collect_ptrace_register) (linux_process_target::low_supply_ptrace_register): Define. Update the callers below. (linux_process_target::fetch_register) (linux_process_target::store_register) * linux-x86-low.cc (the_low_target): Remove the op fields. * linux-aarch64-low.cc (the_low_target): Ditto. * linux-arm-low.cc (the_low_target): Ditto. * linux-bfin-low.cc (the_low_target): Ditto. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-sparc-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto. * linux-mips-low.cc (class mips_target) <low_collect_ptrace_register> <low_supply_ptrace_register>: Declare. (mips_collect_ptrace_register): Turn into ... (mips_target::low_collect_ptrace_register): ...this. (mips_supply_ptrace_register): Turn into... (mips_target::low_supply_ptrace_register): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_collect_ptrace_register> <low_supply_ptrace_register>: Declare. (ppc_collect_ptrace_register): Turn into ... (ppc_target::low_collect_ptrace_register): ...this. (ppc_supply_ptrace_register): Turn into ... (ppc_target::low_supply_ptrace_register): ...this. (ppc_fill_gregset): Update for the calls to low_collect_ptrace_register. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_collect_ptrace_register> <low_supply_ptrace_register>: Declare. (s390_collect_ptrace_register): Turn into ... (s390_target::low_collect_ptrace_register): ...this. (s390_supply_ptrace_register): Turn into ... (s390_target::low_supply_ptrace_register): ...this. (s390_fill_gregset): Update for the calls to low_collect_ptrace_register. (the_low_target): Remove the op fields.
2020-04-02 15:11:28 +02:00
low_supply_ptrace_register (regcache, regno, buf);
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
}
gdbserver/linux-low: turn 'cannot_{fetch/store}_register' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'cannot_fetch_register' and 'cannot_store_register' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the low target ops. (class linux_process_target) <fetch_register> <store_register> <usr_fetch_inferior_registers> <usr_store_inferior_registers> <low_cannot_fetch_register> <low_cannot_fetch_register> Declare. * linux-low.cc (fetch_register): Turn into... (linux_process_target::fetch_register): ...this. (store_register): Turn into ... (linux_process_target::store_register): ...this. (usr_fetch_inferior_registers): Turn into... (linux_process_target::usr_fetch_inferior_registers): ...this. (usr_store_inferior_registers): Turn into... (linux_process_target::usr_store_inferior_registers): ...this. * linux-x86-low.cc (class x86_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (x86_cannot_store_register): Turn into... (x86_target::low_cannot_store_register): ...this. (x86_cannot_fetch_register): Turn into... (x86_target::low_cannot_fetch_register): ...this. (the_low_target): Remove the target op fields. * linux-aarch64-low.cc (class aarch64_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (aarch64_target::low_cannot_fetch_register) (aarch64_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (arm_cannot_fetch_register): Turn into... (arm_target::low_cannot_fetch_register): ...this. (arm_cannot_store_register): Turn into... (arm_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (bfin_cannot_fetch_register): Turn into... (bfin_target::low_cannot_fetch_register): ...this. (bfin_cannot_store_register): Turn into... (bfin_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (cris_cannot_fetch_register): Turn into... (cris_target::low_cannot_fetch_register): ...this. (cris_cannot_store_register): Turn into... (cris_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (crisv32_target::low_cannot_fetch_register) (crisv32_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-ia64-low.cc (class ia64_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (ia64_cannot_fetch_register): Turn into... (ia64_target::low_cannot_fetch_register): ...this. (ia64_cannot_store_register): Turn into... (ia64_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (m32r_cannot_fetch_register): Turn into... (m32r_target::low_cannot_fetch_register): ...this. (m32r_cannot_store_register): Turn into... (m32r_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (m68k_cannot_fetch_register): Turn into... (m68k_target::low_cannot_fetch_register): ...this. (m68k_cannot_store_register): Turn into... (m68k_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (mips_cannot_fetch_register): Turn into... (mips_target::low_cannot_fetch_register): ...this. (mips_cannot_store_register): Turn into... (mips_target::low_cannot_store_register): ...this. (get_usrregs_info): Inline at the call sites in low_cannot_fetch_register and low_cannot_store_register, and remove. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (nios2_cannot_fetch_register): Turn into... (nios2_target::low_cannot_fetch_register): ...this. (nios2_cannot_store_register): Turn into... (nios2_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (ppc_cannot_fetch_register): Turn into... (ppc_target::low_cannot_fetch_register): ...this. (ppc_cannot_store_register): Turn into... (ppc_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (riscv_target::low_cannot_fetch_register) (riscv_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (s390_cannot_fetch_register): Turn into... (s390_target::low_cannot_fetch_register): ...this. (s390_cannot_store_register): Turn into... (s390_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (sh_cannot_fetch_register): Turn into... (sh_target::low_cannot_fetch_register): ...this. (sh_cannot_store_register): Turn into... (sh_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (sparc_cannot_fetch_register): Turn into... (sparc_target::low_cannot_fetch_register): ...this. (sparc_cannot_store_register): Turn into... (sparc_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (tic6x_cannot_fetch_register): Turn into... (tic6x_target::low_cannot_fetch_register): ...this. (tic6x_cannot_store_register): Turn into... (tic6x_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (tile_cannot_fetch_register): Turn into... (tile_target::low_cannot_fetch_register): ...this. (tile_cannot_store_register): Turn into... (tile_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (xtensa_target::low_cannot_fetch_register) (xtensa_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
void
linux_process_target::store_register (const usrregs_info *usrregs,
regcache *regcache, int regno)
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
{
CORE_ADDR regaddr;
int i, size;
char *buf;
int pid;
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
if (regno >= usrregs->num_regs)
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
return;
gdbserver/linux-low: turn 'cannot_{fetch/store}_register' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'cannot_fetch_register' and 'cannot_store_register' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the low target ops. (class linux_process_target) <fetch_register> <store_register> <usr_fetch_inferior_registers> <usr_store_inferior_registers> <low_cannot_fetch_register> <low_cannot_fetch_register> Declare. * linux-low.cc (fetch_register): Turn into... (linux_process_target::fetch_register): ...this. (store_register): Turn into ... (linux_process_target::store_register): ...this. (usr_fetch_inferior_registers): Turn into... (linux_process_target::usr_fetch_inferior_registers): ...this. (usr_store_inferior_registers): Turn into... (linux_process_target::usr_store_inferior_registers): ...this. * linux-x86-low.cc (class x86_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (x86_cannot_store_register): Turn into... (x86_target::low_cannot_store_register): ...this. (x86_cannot_fetch_register): Turn into... (x86_target::low_cannot_fetch_register): ...this. (the_low_target): Remove the target op fields. * linux-aarch64-low.cc (class aarch64_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (aarch64_target::low_cannot_fetch_register) (aarch64_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (arm_cannot_fetch_register): Turn into... (arm_target::low_cannot_fetch_register): ...this. (arm_cannot_store_register): Turn into... (arm_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (bfin_cannot_fetch_register): Turn into... (bfin_target::low_cannot_fetch_register): ...this. (bfin_cannot_store_register): Turn into... (bfin_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (cris_cannot_fetch_register): Turn into... (cris_target::low_cannot_fetch_register): ...this. (cris_cannot_store_register): Turn into... (cris_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (crisv32_target::low_cannot_fetch_register) (crisv32_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-ia64-low.cc (class ia64_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (ia64_cannot_fetch_register): Turn into... (ia64_target::low_cannot_fetch_register): ...this. (ia64_cannot_store_register): Turn into... (ia64_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (m32r_cannot_fetch_register): Turn into... (m32r_target::low_cannot_fetch_register): ...this. (m32r_cannot_store_register): Turn into... (m32r_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (m68k_cannot_fetch_register): Turn into... (m68k_target::low_cannot_fetch_register): ...this. (m68k_cannot_store_register): Turn into... (m68k_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (mips_cannot_fetch_register): Turn into... (mips_target::low_cannot_fetch_register): ...this. (mips_cannot_store_register): Turn into... (mips_target::low_cannot_store_register): ...this. (get_usrregs_info): Inline at the call sites in low_cannot_fetch_register and low_cannot_store_register, and remove. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (nios2_cannot_fetch_register): Turn into... (nios2_target::low_cannot_fetch_register): ...this. (nios2_cannot_store_register): Turn into... (nios2_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (ppc_cannot_fetch_register): Turn into... (ppc_target::low_cannot_fetch_register): ...this. (ppc_cannot_store_register): Turn into... (ppc_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (riscv_target::low_cannot_fetch_register) (riscv_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (s390_cannot_fetch_register): Turn into... (s390_target::low_cannot_fetch_register): ...this. (s390_cannot_store_register): Turn into... (s390_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (sh_cannot_fetch_register): Turn into... (sh_target::low_cannot_fetch_register): ...this. (sh_cannot_store_register): Turn into... (sh_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (sparc_cannot_fetch_register): Turn into... (sparc_target::low_cannot_fetch_register): ...this. (sparc_cannot_store_register): Turn into... (sparc_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (tic6x_cannot_fetch_register): Turn into... (tic6x_target::low_cannot_fetch_register): ...this. (tic6x_cannot_store_register): Turn into... (tic6x_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (tile_cannot_fetch_register): Turn into... (tile_target::low_cannot_fetch_register): ...this. (tile_cannot_store_register): Turn into... (tile_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (xtensa_target::low_cannot_fetch_register) (xtensa_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
if (low_cannot_store_register (regno))
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
return;
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
regaddr = register_addr (usrregs, regno);
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
if (regaddr == -1)
return;
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
size = ((register_size (regcache->tdesc, regno)
+ sizeof (PTRACE_XFER_TYPE) - 1)
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
& -sizeof (PTRACE_XFER_TYPE));
Add casts to memory allocation related calls Most allocation functions (if not all) return a void* pointing to the allocated memory. In C++, we need to add an explicit cast when assigning the result to a pointer to another type (which is the case more often than not). The content of this patch is taken from Pedro's branch, from commit "(mostly) auto-generated patch to insert casts needed for C++". I validated that the changes make sense and manually reflowed the code to make it respect the coding style. I also found multiple places where I could use XNEW/XNEWVEC/XRESIZEVEC/etc. Thanks a lot to whoever did that automated script to insert casts, doing it completely by hand would have taken a ridiculous amount of time. Only files built on x86 with --enable-targets=all are modified. This means that all other -nat.c files are untouched and will have to be dealt with later by using appropiate compilers. Or maybe we can try to build them with a regular g++ just to know where to add casts, I don't know. I built-tested this with --enable-targets=all and reg-tested. Here's the changelog entry, which was not too bad to make despite the size, thanks to David Malcom's script. I fixed some bits by hand, but there might be some wrong parts left (hopefully not). gdb/ChangeLog: * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Add cast to allocation result assignment. * ada-exp.y (write_object_renaming): Likewise. (write_ambiguous_var): Likewise. (ada_nget_field_index): Likewise. (write_var_or_type): Likewise. * ada-lang.c (ada_decode_symbol): Likewise. (ada_value_assign): Likewise. (value_pointer): Likewise. (cache_symbol): Likewise. (add_nonlocal_symbols): Likewise. (ada_name_for_lookup): Likewise. (symbol_completion_add): Likewise. (ada_to_fixed_type_1): Likewise. (ada_get_next_arg): Likewise. (defns_collected): Likewise. * ada-lex.l (processId): Likewise. (processString): Likewise. * ada-tasks.c (read_known_tasks_array): Likewise. (read_known_tasks_list): Likewise. * ada-typeprint.c (decoded_type_name): Likewise. * addrmap.c (addrmap_mutable_create_fixed): Likewise. * amd64-tdep.c (amd64_push_arguments): Likewise. (amd64_displaced_step_copy_insn): Likewise. (amd64_classify_insn_at): Likewise. (amd64_relocate_instruction): Likewise. * amd64obsd-tdep.c (amd64obsd_sigtramp_p): Likewise. * arch-utils.c (simple_displaced_step_copy_insn): Likewise. (initialize_current_architecture): Likewise. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * arm-symbian-tdep.c (arm_symbian_osabi_sniffer): Likewise. * arm-tdep.c (arm_exidx_new_objfile): Likewise. (arm_push_dummy_call): Likewise. (extend_buffer_earlier): Likewise. (arm_adjust_breakpoint_address): Likewise. (arm_skip_stub): Likewise. * auto-load.c (filename_is_in_pattern): Likewise. (maybe_add_script_file): Likewise. (maybe_add_script_text): Likewise. (auto_load_objfile_script_1): Likewise. * auxv.c (ld_so_xfer_auxv): Likewise. * ax-general.c (new_agent_expr): Likewise. (grow_expr): Likewise. (ax_reg_mask): Likewise. * bcache.c (bcache_full): Likewise. * breakpoint.c (program_breakpoint_here_p): Likewise. * btrace.c (parse_xml_raw): Likewise. * build-id.c (build_id_to_debug_bfd): Likewise. * buildsym.c (end_symtab_with_blockvector): Likewise. * c-exp.y (string_exp): Likewise. (qualified_name): Likewise. (write_destructor_name): Likewise. (operator_stoken): Likewise. (parse_number): Likewise. (scan_macro_expansion): Likewise. (yylex): Likewise. (c_print_token): Likewise. * c-lang.c (c_get_string): Likewise. (emit_numeric_character): Likewise. * charset.c (wchar_iterate): Likewise. * cli/cli-cmds.c (complete_command): Likewise. (make_command): Likewise. * cli/cli-dump.c (restore_section_callback): Likewise. (restore_binary_file): Likewise. * cli/cli-interp.c (cli_interpreter_exec): Likewise. * cli/cli-script.c (execute_control_command): Likewise. * cli/cli-setshow.c (do_set_command): Likewise. * coff-pe-read.c (add_pe_forwarded_sym): Likewise. (read_pe_exported_syms): Likewise. * coffread.c (coff_read_struct_type): Likewise. (coff_read_enum_type): Likewise. * common/btrace-common.c (btrace_data_append): Likewise. * common/buffer.c (buffer_grow): Likewise. * common/filestuff.c (gdb_fopen_cloexec): Likewise. * common/format.c (parse_format_string): Likewise. * common/gdb_vecs.c (delim_string_to_char_ptr_vec_append): Likewise. * common/xml-utils.c (xml_escape_text): Likewise. * compile/compile-object-load.c (copy_sections): Likewise. (compile_object_load): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * completer.c (filename_completer): Likewise. * corefile.c (read_memory_typed_address): Likewise. (write_memory_unsigned_integer): Likewise. (write_memory_signed_integer): Likewise. (complete_set_gnutarget): Likewise. * corelow.c (get_core_register_section): Likewise. * cp-name-parser.y (d_grab): Likewise. (allocate_info): Likewise. (cp_new_demangle_parse_info): Likewise. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Likewise. (cp_lookup_symbol_in_namespace): Likewise. (lookup_namespace_scope): Likewise. (find_symbol_in_baseclass): Likewise. (cp_lookup_nested_symbol): Likewise. (cp_lookup_transparent_type_loop): Likewise. * cp-support.c (copy_string_to_obstack): Likewise. (make_symbol_overload_list): Likewise. (make_symbol_overload_list_namespace): Likewise. (make_symbol_overload_list_adl_namespace): Likewise. (first_component_command): Likewise. * cp-valprint.c (cp_print_value): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * d-exp.y (StringExp): Likewise. * d-namespace.c (d_lookup_symbol_in_module): Likewise. (lookup_module_scope): Likewise. (find_symbol_in_baseclass): Likewise. (d_lookup_nested_symbol): Likewise. * dbxread.c (find_stab_function_addr): Likewise. (read_dbx_symtab): Likewise. (dbx_end_psymtab): Likewise. (cp_set_block_scope): Likewise. * dcache.c (dcache_alloc): Likewise. * demangle.c (_initialize_demangler): Likewise. * dicos-tdep.c (dicos_load_module_p): Likewise. * dictionary.c (dict_create_hashed_expandable): Likewise. (dict_create_linear_expandable): Likewise. (expand_hashtable): Likewise. (add_symbol_linear_expandable): Likewise. * dwarf2-frame.c (add_cie): Likewise. (add_fde): Likewise. (dwarf2_build_frame_info): Likewise. * dwarf2expr.c (dwarf_expr_grow_stack): Likewise. (dwarf_expr_fetch_address): Likewise. (add_piece): Likewise. (execute_stack_op): Likewise. * dwarf2loc.c (chain_candidate): Likewise. (dwarf_entry_parameter_to_value): Likewise. (read_pieced_value): Likewise. (write_pieced_value): Likewise. * dwarf2read.c (dwarf2_read_section): Likewise. (add_type_unit): Likewise. (read_comp_units_from_section): Likewise. (fixup_go_packaging): Likewise. (dwarf2_compute_name): Likewise. (dwarf2_physname): Likewise. (create_dwo_unit_in_dwp_v1): Likewise. (create_dwo_unit_in_dwp_v2): Likewise. (read_func_scope): Likewise. (read_call_site_scope): Likewise. (dwarf2_attach_fields_to_type): Likewise. (process_structure_scope): Likewise. (mark_common_block_symbol_computed): Likewise. (read_common_block): Likewise. (abbrev_table_read_table): Likewise. (guess_partial_die_structure_name): Likewise. (fixup_partial_die): Likewise. (add_file_name): Likewise. (dwarf2_const_value_data): Likewise. (dwarf2_const_value_attr): Likewise. (build_error_marker_type): Likewise. (guess_full_die_structure_name): Likewise. (anonymous_struct_prefix): Likewise. (typename_concat): Likewise. (dwarf2_canonicalize_name): Likewise. (dwarf2_name): Likewise. (write_constant_as_bytes): Likewise. (dwarf2_fetch_constant_bytes): Likewise. (copy_string): Likewise. (parse_macro_definition): Likewise. * elfread.c (elf_symfile_segments): Likewise. (elf_rel_plt_read): Likewise. (elf_gnu_ifunc_resolve_by_cache): Likewise. (elf_gnu_ifunc_resolve_by_got): Likewise. (elf_read_minimal_symbols): Likewise. (elf_gnu_ifunc_record_cache): Likewise. * event-top.c (top_level_prompt): Likewise. (command_line_handler): Likewise. * exec.c (resize_section_table): Likewise. * expprint.c (print_subexp_standard): Likewise. * fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise. * findcmd.c (parse_find_args): Likewise. * findvar.c (address_from_register): Likewise. * frame.c (get_prev_frame_always): Likewise. * gdb_bfd.c (gdb_bfd_ref): Likewise. (get_section_descriptor): Likewise. * gdb_obstack.c (obconcat): Likewise. (obstack_strdup): Likewise. * gdbtypes.c (lookup_function_type_with_arguments): Likewise. (create_set_type): Likewise. (lookup_unsigned_typename): Likewise. (lookup_signed_typename): Likewise. (resolve_dynamic_union): Likewise. (resolve_dynamic_struct): Likewise. (add_dyn_prop): Likewise. (copy_dynamic_prop_list): Likewise. (arch_flags_type): Likewise. (append_composite_type_field_raw): Likewise. * gdbtypes.h (INIT_FUNC_SPECIFIC): Likewise. * gnu-v3-abi.c (gnuv3_rtti_type): Likewise. * go-exp.y (string_exp): Likewise. * go-lang.c (go_demangle): Likewise. * guile/guile.c (compute_scheme_string): Likewise. * guile/scm-cmd.c (gdbscm_parse_command_name): Likewise. (gdbscm_canonicalize_command_name): Likewise. * guile/scm-ports.c (ioscm_init_stdio_buffers): Likewise. (ioscm_init_memory_port): Likewise. (ioscm_reinit_memory_port): Likewise. * guile/scm-utils.c (gdbscm_gc_xstrdup): Likewise. (gdbscm_gc_dup_argv): Likewise. * h8300-tdep.c (h8300_push_dummy_call): Likewise. * hppa-tdep.c (internalize_unwinds): Likewise. (read_unwind_info): Likewise. * i386-cygwin-tdep.c (core_process_module_section): Likewise. (windows_core_xfer_shared_libraries): Likewise. * i386-tdep.c (i386_displaced_step_copy_insn): Likewise. (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * i386obsd-tdep.c (i386obsd_sigtramp_p): Likewise. * inf-child.c (inf_child_fileio_readlink): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_store_register): Likewise. * infrun.c (follow_exec): Likewise. (displaced_step_prepare_throw): Likewise. (save_stop_context): Likewise. (save_infcall_suspend_state): Likewise. * jit.c (jit_read_descriptor): Likewise. (jit_read_code_entry): Likewise. (jit_symtab_line_mapping_add_impl): Likewise. (finalize_symtab): Likewise. (jit_unwind_reg_get_impl): Likewise. * jv-exp.y (QualifiedName): Likewise. * jv-lang.c (get_java_utf8_name): Likewise. (type_from_class): Likewise. (java_demangle_type_signature): Likewise. (java_class_name_from_physname): Likewise. * jv-typeprint.c (java_type_print_base): Likewise. * jv-valprint.c (java_value_print): Likewise. * language.c (add_language): Likewise. * linespec.c (add_sal_to_sals_basic): Likewise. (add_sal_to_sals): Likewise. (decode_objc): Likewise. (find_linespec_symbols): Likewise. * linux-fork.c (fork_save_infrun_state): Likewise. * linux-nat.c (linux_nat_detach): Likewise. (linux_nat_fileio_readlink): Likewise. * linux-record.c (record_linux_sockaddr): Likewise. (record_linux_msghdr): Likewise. (Do): Likewise. * linux-tdep.c (linux_core_info_proc_mappings): Likewise. (linux_collect_regset_section_cb): Likewise. (linux_get_siginfo_data): Likewise. * linux-thread-db.c (try_thread_db_load_from_pdir_1): Likewise. (try_thread_db_load_from_dir): Likewise. (thread_db_load_search): Likewise. (info_auto_load_libthread_db): Likewise. * m32c-tdep.c (m32c_m16c_address_to_pointer): Likewise. (m32c_m16c_pointer_to_address): Likewise. * m68hc11-tdep.c (m68hc11_pseudo_register_write): Likewise. * m68k-tdep.c (m68k_get_longjmp_target): Likewise. * machoread.c (macho_check_dsym): Likewise. * macroexp.c (resize_buffer): Likewise. (gather_arguments): Likewise. (maybe_expand): Likewise. * macrotab.c (new_macro_key): Likewise. (new_source_file): Likewise. (new_macro_definition): Likewise. * mdebugread.c (parse_symbol): Likewise. (parse_type): Likewise. (parse_partial_symbols): Likewise. (psymtab_to_symtab_1): Likewise. * mem-break.c (default_memory_insert_breakpoint): Likewise. * mi/mi-cmd-break.c (mi_argv_to_format): Likewise. * mi/mi-main.c (mi_cmd_data_read_memory): Likewise. (mi_cmd_data_read_memory_bytes): Likewise. (mi_cmd_data_write_memory_bytes): Likewise. (mi_cmd_trace_frame_collected): Likewise. * mi/mi-parse.c (mi_parse_argv): Likewise. (mi_parse): Likewise. * minidebug.c (lzma_open): Likewise. (lzma_pread): Likewise. * mips-tdep.c (mips_read_fp_register_single): Likewise. (mips_print_fp_register): Likewise. * mipsnbsd-tdep.c (mipsnbsd_get_longjmp_target): Likewise. * mipsread.c (read_alphacoff_dynamic_symtab): Likewise. * mt-tdep.c (mt_register_name): Likewise. (mt_registers_info): Likewise. (mt_push_dummy_call): Likewise. * namespace.c (add_using_directive): Likewise. * nat/linux-btrace.c (perf_event_read): Likewise. (linux_enable_bts): Likewise. * nat/linux-osdata.c (linux_common_core_of_thread): Likewise. * nat/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Likewise. * nto-tdep.c (nto_find_and_open_solib): Likewise. (nto_parse_redirection): Likewise. * objc-lang.c (objc_demangle): Likewise. (find_methods): Likewise. * objfiles.c (get_objfile_bfd_data): Likewise. (set_objfile_main_name): Likewise. (allocate_objfile): Likewise. (objfile_relocate): Likewise. (update_section_map): Likewise. * osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Likewise. * p-exp.y (exp): Likewise. (yylex): Likewise. * p-valprint.c (pascal_object_print_value): Likewise. * parse.c (initialize_expout): Likewise. (mark_completion_tag): Likewise. (copy_name): Likewise. (parse_float): Likewise. (type_stack_reserve): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. (ppu2spu_prev_register): Likewise. * ppc-ravenscar-thread.c (supply_register_at_address): Likewise. * printcmd.c (printf_wide_c_string): Likewise. (printf_pointer): Likewise. * probe.c (parse_probes): Likewise. * python/py-cmd.c (gdbpy_parse_command_name): Likewise. (cmdpy_init): Likewise. * python/py-gdb-readline.c (gdbpy_readline_wrapper): Likewise. * python/py-symtab.c (set_sal): Likewise. * python/py-unwind.c (pyuw_sniffer): Likewise. * python/python.c (python_interactive_command): Likewise. (compute_python_string): Likewise. * ravenscar-thread.c (get_running_thread_id): Likewise. * record-full.c (record_full_exec_insn): Likewise. (record_full_core_open_1): Likewise. * regcache.c (regcache_raw_read_signed): Likewise. (regcache_raw_read_unsigned): Likewise. (regcache_cooked_read_signed): Likewise. (regcache_cooked_read_unsigned): Likewise. * remote-fileio.c (remote_fileio_func_open): Likewise. (remote_fileio_func_rename): Likewise. (remote_fileio_func_unlink): Likewise. (remote_fileio_func_stat): Likewise. (remote_fileio_func_system): Likewise. * remote-mips.c (mips_xfer_memory): Likewise. (mips_load_srec): Likewise. (pmon_end_download): Likewise. * remote.c (new_remote_state): Likewise. (map_regcache_remote_table): Likewise. (remote_register_number_and_offset): Likewise. (init_remote_state): Likewise. (get_memory_packet_size): Likewise. (remote_pass_signals): Likewise. (remote_program_signals): Likewise. (remote_start_remote): Likewise. (remote_check_symbols): Likewise. (remote_query_supported): Likewise. (extended_remote_attach): Likewise. (process_g_packet): Likewise. (store_registers_using_G): Likewise. (putpkt_binary): Likewise. (read_frame): Likewise. (compare_sections_command): Likewise. (remote_hostio_pread): Likewise. (remote_hostio_readlink): Likewise. (remote_file_put): Likewise. (remote_file_get): Likewise. (remote_pid_to_exec_file): Likewise. (_initialize_remote): Likewise. * rs6000-aix-tdep.c (rs6000_aix_ld_info_to_xml): Likewise. (rs6000_aix_core_xfer_shared_libraries_aix): Likewise. * rs6000-tdep.c (ppc_displaced_step_copy_insn): Likewise. (bfd_uses_spe_extensions): Likewise. * s390-linux-tdep.c (s390_displaced_step_copy_insn): Likewise. * score-tdep.c (score7_malloc_and_get_memblock): Likewise. * solib-dsbt.c (decode_loadmap): Likewise. (fetch_loadmap): Likewise. (scan_dyntag): Likewise. (enable_break): Likewise. (dsbt_relocate_main_executable): Likewise. * solib-frv.c (fetch_loadmap): Likewise. (enable_break2): Likewise. (frv_relocate_main_executable): Likewise. * solib-spu.c (spu_relocate_main_executable): Likewise. (spu_bfd_open): Likewise. * solib-svr4.c (lm_info_read): Likewise. (read_program_header): Likewise. (find_program_interpreter): Likewise. (scan_dyntag): Likewise. (elf_locate_base): Likewise. (open_symbol_file_object): Likewise. (read_program_headers_from_bfd): Likewise. (svr4_relocate_main_executable): Likewise. * solib-target.c (solib_target_relocate_section_addresses): Likewise. * solib.c (solib_find_1): Likewise. (exec_file_find): Likewise. (solib_find): Likewise. * source.c (openp): Likewise. (print_source_lines_base): Likewise. (forward_search_command): Likewise. * sparc-ravenscar-thread.c (supply_register_at_address): Likewise. * spu-tdep.c (spu2ppu_prev_register): Likewise. (spu_get_overlay_table): Likewise. * stabsread.c (patch_block_stabs): Likewise. (define_symbol): Likewise. (again:): Likewise. (read_member_functions): Likewise. (read_one_struct_field): Likewise. (read_enum_type): Likewise. (common_block_start): Likewise. * stack.c (read_frame_arg): Likewise. (backtrace_command): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. * symfile.c (syms_from_objfile_1): Likewise. (find_separate_debug_file): Likewise. (load_command): Likewise. (load_progress): Likewise. (load_section_callback): Likewise. (reread_symbols): Likewise. (add_filename_language): Likewise. (allocate_compunit_symtab): Likewise. (read_target_long_array): Likewise. (simple_read_overlay_table): Likewise. * symtab.c (symbol_set_names): Likewise. (resize_symbol_cache): Likewise. (rbreak_command): Likewise. (completion_list_add_name): Likewise. (completion_list_objc_symbol): Likewise. (add_filename_to_list): Likewise. * target-descriptions.c (maint_print_c_tdesc_cmd): Likewise. * target-memory.c (target_write_memory_blocks): Likewise. * target.c (target_read_string): Likewise. (read_whatever_is_readable): Likewise. (target_read_alloc_1): Likewise. (simple_search_memory): Likewise. (target_fileio_read_alloc_1): Likewise. * tilegx-tdep.c (tilegx_push_dummy_call): Likewise. * top.c (command_line_input): Likewise. * tracefile-tfile.c (tfile_fetch_registers): Likewise. * tracefile.c (tracefile_fetch_registers): Likewise. * tracepoint.c (add_memrange): Likewise. (init_collection_list): Likewise. (add_aexpr): Likewise. (trace_dump_actions): Likewise. (parse_trace_status): Likewise. (parse_tracepoint_definition): Likewise. (parse_tsv_definition): Likewise. (parse_static_tracepoint_marker_definition): Likewise. * tui/tui-file.c (tui_sfileopen): Likewise. (tui_file_adjust_strbuf): Likewise. * tui/tui-io.c (tui_expand_tabs): Likewise. * tui/tui-source.c (tui_set_source_content): Likewise. * typeprint.c (find_global_typedef): Likewise. * ui-file.c (do_ui_file_xstrdup): Likewise. (ui_file_obsavestring): Likewise. (mem_file_write): Likewise. * utils.c (make_hex_string): Likewise. (get_regcomp_error): Likewise. (puts_filtered_tabular): Likewise. (gdb_realpath_keepfile): Likewise. (ldirname): Likewise. (gdb_bfd_errmsg): Likewise. (substitute_path_component): Likewise. * valops.c (search_struct_method): Likewise. (find_oload_champ_namespace_loop): Likewise. * valprint.c (print_decimal_chars): Likewise. (read_string): Likewise. (generic_emit_char): Likewise. * varobj.c (varobj_delete): Likewise. (varobj_value_get_print_value): Likewise. * vaxobsd-tdep.c (vaxobsd_sigtramp_sniffer): Likewise. * windows-tdep.c (display_one_tib): Likewise. * xcoffread.c (read_xcoff_symtab): Likewise. (process_xcoff_symbol): Likewise. (swap_sym): Likewise. (scan_xcoff_symtab): Likewise. (xcoff_initial_scan): Likewise. * xml-support.c (gdb_xml_end_element): Likewise. (xml_process_xincludes): Likewise. (xml_fetch_content_from_file): Likewise. * xml-syscall.c (xml_list_of_syscalls): Likewise. * xstormy16-tdep.c (xstormy16_push_dummy_call): Likewise. gdb/gdbserver/ChangeLog: * ax.c (gdb_parse_agent_expr): Add cast to allocation result assignment. (gdb_unparse_agent_expr): Likewise. * hostio.c (require_data): Likewise. (handle_pread): Likewise. * linux-low.c (disable_regset): Likewise. (fetch_register): Likewise. (store_register): Likewise. (get_dynamic): Likewise. (linux_qxfer_libraries_svr4): Likewise. * mem-break.c (delete_fast_tracepoint_jump): Likewise. (set_fast_tracepoint_jump): Likewise. (uninsert_fast_tracepoint_jumps_at): Likewise. (reinsert_fast_tracepoint_jumps_at): Likewise. (validate_inserted_breakpoint): Likewise. (clone_agent_expr): Likewise. * regcache.c (init_register_cache): Likewise. * remote-utils.c (putpkt_binary_1): Likewise. (decode_M_packet): Likewise. (decode_X_packet): Likewise. (look_up_one_symbol): Likewise. (relocate_instruction): Likewise. (monitor_output): Likewise. * server.c (handle_search_memory): Likewise. (handle_qxfer_exec_file): Likewise. (handle_qxfer_libraries): Likewise. (handle_qxfer): Likewise. (handle_query): Likewise. (handle_v_cont): Likewise. (handle_v_run): Likewise. (captured_main): Likewise. * target.c (write_inferior_memory): Likewise. * thread-db.c (try_thread_db_load_from_dir): Likewise. * tracepoint.c (init_trace_buffer): Likewise. (add_tracepoint_action): Likewise. (add_traceframe): Likewise. (add_traceframe_block): Likewise. (cmd_qtdpsrc): Likewise. (cmd_qtdv): Likewise. (cmd_qtstatus): Likewise. (response_source): Likewise. (response_tsv): Likewise. (cmd_qtnotes): Likewise. (gdb_collect): Likewise. (initialize_tracepoint): Likewise.
2015-09-25 20:08:06 +02:00
buf = (char *) alloca (size);
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
memset (buf, 0, size);
gdbserver/linux-low: turn '{collect, supply}_ptrace_register' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'collect_ptrace_register' and 'supply_ptrace_register' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <low_collect_ptrace_register> <low_store_ptrace_register>: Declare. * linux-low.cc (linux_process_target::low_collect_ptrace_register) (linux_process_target::low_supply_ptrace_register): Define. Update the callers below. (linux_process_target::fetch_register) (linux_process_target::store_register) * linux-x86-low.cc (the_low_target): Remove the op fields. * linux-aarch64-low.cc (the_low_target): Ditto. * linux-arm-low.cc (the_low_target): Ditto. * linux-bfin-low.cc (the_low_target): Ditto. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-sparc-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto. * linux-mips-low.cc (class mips_target) <low_collect_ptrace_register> <low_supply_ptrace_register>: Declare. (mips_collect_ptrace_register): Turn into ... (mips_target::low_collect_ptrace_register): ...this. (mips_supply_ptrace_register): Turn into... (mips_target::low_supply_ptrace_register): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_collect_ptrace_register> <low_supply_ptrace_register>: Declare. (ppc_collect_ptrace_register): Turn into ... (ppc_target::low_collect_ptrace_register): ...this. (ppc_supply_ptrace_register): Turn into ... (ppc_target::low_supply_ptrace_register): ...this. (ppc_fill_gregset): Update for the calls to low_collect_ptrace_register. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_collect_ptrace_register> <low_supply_ptrace_register>: Declare. (s390_collect_ptrace_register): Turn into ... (s390_target::low_collect_ptrace_register): ...this. (s390_supply_ptrace_register): Turn into ... (s390_target::low_supply_ptrace_register): ...this. (s390_fill_gregset): Update for the calls to low_collect_ptrace_register. (the_low_target): Remove the op fields.
2020-04-02 15:11:28 +02:00
low_collect_ptrace_register (regcache, regno, buf);
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
pid = lwpid_of (current_thread);
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
for (i = 0; i < size; i += sizeof (PTRACE_XFER_TYPE))
{
errno = 0;
ptrace (PTRACE_POKEUSER, pid,
/* Coerce to a uintptr_t first to avoid potential gcc warning
about coercing an 8 byte integer to a 4 byte pointer. */
(PTRACE_TYPE_ARG3) (uintptr_t) regaddr,
(PTRACE_TYPE_ARG4) *(PTRACE_XFER_TYPE *) (buf + i));
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
if (errno != 0)
{
/* At this point, ESRCH should mean the process is
already gone, in which case we simply ignore attempts
to change its registers. See also the related
gdbserver/linux-low: turn some more static functions into private methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn some more static methods in linux-low into private methods of linux_process_target. * linux-low.cc (get_pc): Turn into... (linux_process_target::get_pc): ...this. (save_stop_reason): Turn into... (linux_process_target::save_stop_reason): ...this. (thread_still_has_status_pending_p): Turn into... (linux_process_target::thread_still_has_status_pending): ...this. (status_pending_p_callback): Turn into... (linux_process_target::status_pending_p_callback): ...this. (resume_stopped_resumed_lwps): Turn into... (linux_process_target::resume_stopped_resumed_lwps): ...this. (install_software_single_step_breakpoints): Turn into... (linux_process_target::install_software_single_step_breakpoints): ...this. (single_step): Turn into... (linux_process_target::single_step): ...this. (linux_resume_one_lwp_throw): Turn into... (linux_process_target::resume_one_lwp_throw): ...this. (linux_resume_one_lwp): Turn into... (linux_process_target::resume_one_lwp): ...this. (resume_status_pending_p): Turn into... (linux_process_target::resume_status_pending): ...this. (need_step_over_p): Turn into... (linux_process_target::thread_needs_step_over): ...this. (linux_resume_one_thread): Turn into... (linux_process_target::resume_one_thread): ...this. (proceed_one_lwp): Turn into... (linux_process_target::proceed_one_lwp): ...this. (unsuspend_and_proceed_one_lwp): Turn into... (linux_process_target::unsuspend_and_proceed_one_lwp): ...this. Update the calls/references to the above functions below. (linux_process_target::handle_extended_wait) (linux_process_target::filter_event) (linux_process_target::wait_for_event_filtered) (linux_process_target::wait_1) (linux_process_target::move_out_of_jump_pad) (linux_process_target::start_step_over) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (regsets_store_inferior_registers) (linux_process_target::store_register) * linux-low.h (class linux_process_target) <get_pc> <save_stop_reason> <thread_still_has_status_pending> <status_pending_p_callback> <resume_stopped_resumed_lwps> <install_software_single_step_breakpoints> <single_step> <resume_one_lwp_throw> <resume_one_lwp> <resume_status_pending> <thread_needs_step_over> <resume_one_thread> <proceed_one_lwp> <unsuspend_and_proceed_one_lwp>: Declare.
2020-04-02 15:11:24 +02:00
comment in resume_one_lwp. */
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
if (errno == ESRCH)
return;
gdbserver/linux-low: turn 'cannot_{fetch/store}_register' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'cannot_fetch_register' and 'cannot_store_register' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the low target ops. (class linux_process_target) <fetch_register> <store_register> <usr_fetch_inferior_registers> <usr_store_inferior_registers> <low_cannot_fetch_register> <low_cannot_fetch_register> Declare. * linux-low.cc (fetch_register): Turn into... (linux_process_target::fetch_register): ...this. (store_register): Turn into ... (linux_process_target::store_register): ...this. (usr_fetch_inferior_registers): Turn into... (linux_process_target::usr_fetch_inferior_registers): ...this. (usr_store_inferior_registers): Turn into... (linux_process_target::usr_store_inferior_registers): ...this. * linux-x86-low.cc (class x86_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (x86_cannot_store_register): Turn into... (x86_target::low_cannot_store_register): ...this. (x86_cannot_fetch_register): Turn into... (x86_target::low_cannot_fetch_register): ...this. (the_low_target): Remove the target op fields. * linux-aarch64-low.cc (class aarch64_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (aarch64_target::low_cannot_fetch_register) (aarch64_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (arm_cannot_fetch_register): Turn into... (arm_target::low_cannot_fetch_register): ...this. (arm_cannot_store_register): Turn into... (arm_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (bfin_cannot_fetch_register): Turn into... (bfin_target::low_cannot_fetch_register): ...this. (bfin_cannot_store_register): Turn into... (bfin_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (cris_cannot_fetch_register): Turn into... (cris_target::low_cannot_fetch_register): ...this. (cris_cannot_store_register): Turn into... (cris_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (crisv32_target::low_cannot_fetch_register) (crisv32_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-ia64-low.cc (class ia64_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (ia64_cannot_fetch_register): Turn into... (ia64_target::low_cannot_fetch_register): ...this. (ia64_cannot_store_register): Turn into... (ia64_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (m32r_cannot_fetch_register): Turn into... (m32r_target::low_cannot_fetch_register): ...this. (m32r_cannot_store_register): Turn into... (m32r_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (m68k_cannot_fetch_register): Turn into... (m68k_target::low_cannot_fetch_register): ...this. (m68k_cannot_store_register): Turn into... (m68k_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (mips_cannot_fetch_register): Turn into... (mips_target::low_cannot_fetch_register): ...this. (mips_cannot_store_register): Turn into... (mips_target::low_cannot_store_register): ...this. (get_usrregs_info): Inline at the call sites in low_cannot_fetch_register and low_cannot_store_register, and remove. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (nios2_cannot_fetch_register): Turn into... (nios2_target::low_cannot_fetch_register): ...this. (nios2_cannot_store_register): Turn into... (nios2_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (ppc_cannot_fetch_register): Turn into... (ppc_target::low_cannot_fetch_register): ...this. (ppc_cannot_store_register): Turn into... (ppc_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (riscv_target::low_cannot_fetch_register) (riscv_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (s390_cannot_fetch_register): Turn into... (s390_target::low_cannot_fetch_register): ...this. (s390_cannot_store_register): Turn into... (s390_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (sh_cannot_fetch_register): Turn into... (sh_target::low_cannot_fetch_register): ...this. (sh_cannot_store_register): Turn into... (sh_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (sparc_cannot_fetch_register): Turn into... (sparc_target::low_cannot_fetch_register): ...this. (sparc_cannot_store_register): Turn into... (sparc_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (tic6x_cannot_fetch_register): Turn into... (tic6x_target::low_cannot_fetch_register): ...this. (tic6x_cannot_store_register): Turn into... (tic6x_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (tile_cannot_fetch_register): Turn into... (tile_target::low_cannot_fetch_register): ...this. (tile_cannot_store_register): Turn into... (tile_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (xtensa_target::low_cannot_fetch_register) (xtensa_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
if (!low_cannot_store_register (regno))
error ("writing register %d: %s", regno, safe_strerror (errno));
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
}
regaddr += sizeof (PTRACE_XFER_TYPE);
}
}
gdbserver/linux-low: turn 'cannot_{fetch/store}_register' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'cannot_fetch_register' and 'cannot_store_register' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the low target ops. (class linux_process_target) <fetch_register> <store_register> <usr_fetch_inferior_registers> <usr_store_inferior_registers> <low_cannot_fetch_register> <low_cannot_fetch_register> Declare. * linux-low.cc (fetch_register): Turn into... (linux_process_target::fetch_register): ...this. (store_register): Turn into ... (linux_process_target::store_register): ...this. (usr_fetch_inferior_registers): Turn into... (linux_process_target::usr_fetch_inferior_registers): ...this. (usr_store_inferior_registers): Turn into... (linux_process_target::usr_store_inferior_registers): ...this. * linux-x86-low.cc (class x86_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (x86_cannot_store_register): Turn into... (x86_target::low_cannot_store_register): ...this. (x86_cannot_fetch_register): Turn into... (x86_target::low_cannot_fetch_register): ...this. (the_low_target): Remove the target op fields. * linux-aarch64-low.cc (class aarch64_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (aarch64_target::low_cannot_fetch_register) (aarch64_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (arm_cannot_fetch_register): Turn into... (arm_target::low_cannot_fetch_register): ...this. (arm_cannot_store_register): Turn into... (arm_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (bfin_cannot_fetch_register): Turn into... (bfin_target::low_cannot_fetch_register): ...this. (bfin_cannot_store_register): Turn into... (bfin_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (cris_cannot_fetch_register): Turn into... (cris_target::low_cannot_fetch_register): ...this. (cris_cannot_store_register): Turn into... (cris_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (crisv32_target::low_cannot_fetch_register) (crisv32_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-ia64-low.cc (class ia64_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (ia64_cannot_fetch_register): Turn into... (ia64_target::low_cannot_fetch_register): ...this. (ia64_cannot_store_register): Turn into... (ia64_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (m32r_cannot_fetch_register): Turn into... (m32r_target::low_cannot_fetch_register): ...this. (m32r_cannot_store_register): Turn into... (m32r_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (m68k_cannot_fetch_register): Turn into... (m68k_target::low_cannot_fetch_register): ...this. (m68k_cannot_store_register): Turn into... (m68k_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (mips_cannot_fetch_register): Turn into... (mips_target::low_cannot_fetch_register): ...this. (mips_cannot_store_register): Turn into... (mips_target::low_cannot_store_register): ...this. (get_usrregs_info): Inline at the call sites in low_cannot_fetch_register and low_cannot_store_register, and remove. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (nios2_cannot_fetch_register): Turn into... (nios2_target::low_cannot_fetch_register): ...this. (nios2_cannot_store_register): Turn into... (nios2_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (ppc_cannot_fetch_register): Turn into... (ppc_target::low_cannot_fetch_register): ...this. (ppc_cannot_store_register): Turn into... (ppc_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (riscv_target::low_cannot_fetch_register) (riscv_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (s390_cannot_fetch_register): Turn into... (s390_target::low_cannot_fetch_register): ...this. (s390_cannot_store_register): Turn into... (s390_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (sh_cannot_fetch_register): Turn into... (sh_target::low_cannot_fetch_register): ...this. (sh_cannot_store_register): Turn into... (sh_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (sparc_cannot_fetch_register): Turn into... (sparc_target::low_cannot_fetch_register): ...this. (sparc_cannot_store_register): Turn into... (sparc_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (tic6x_cannot_fetch_register): Turn into... (tic6x_target::low_cannot_fetch_register): ...this. (tic6x_cannot_store_register): Turn into... (tic6x_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (tile_cannot_fetch_register): Turn into... (tile_target::low_cannot_fetch_register): ...this. (tile_cannot_store_register): Turn into... (tile_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (xtensa_target::low_cannot_fetch_register) (xtensa_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
#endif /* HAVE_LINUX_USRREGS */
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
gdbserver/linux-low: turn '{collect, supply}_ptrace_register' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'collect_ptrace_register' and 'supply_ptrace_register' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <low_collect_ptrace_register> <low_store_ptrace_register>: Declare. * linux-low.cc (linux_process_target::low_collect_ptrace_register) (linux_process_target::low_supply_ptrace_register): Define. Update the callers below. (linux_process_target::fetch_register) (linux_process_target::store_register) * linux-x86-low.cc (the_low_target): Remove the op fields. * linux-aarch64-low.cc (the_low_target): Ditto. * linux-arm-low.cc (the_low_target): Ditto. * linux-bfin-low.cc (the_low_target): Ditto. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-sparc-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto. * linux-mips-low.cc (class mips_target) <low_collect_ptrace_register> <low_supply_ptrace_register>: Declare. (mips_collect_ptrace_register): Turn into ... (mips_target::low_collect_ptrace_register): ...this. (mips_supply_ptrace_register): Turn into... (mips_target::low_supply_ptrace_register): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_collect_ptrace_register> <low_supply_ptrace_register>: Declare. (ppc_collect_ptrace_register): Turn into ... (ppc_target::low_collect_ptrace_register): ...this. (ppc_supply_ptrace_register): Turn into ... (ppc_target::low_supply_ptrace_register): ...this. (ppc_fill_gregset): Update for the calls to low_collect_ptrace_register. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_collect_ptrace_register> <low_supply_ptrace_register>: Declare. (s390_collect_ptrace_register): Turn into ... (s390_target::low_collect_ptrace_register): ...this. (s390_supply_ptrace_register): Turn into ... (s390_target::low_supply_ptrace_register): ...this. (s390_fill_gregset): Update for the calls to low_collect_ptrace_register. (the_low_target): Remove the op fields.
2020-04-02 15:11:28 +02:00
void
linux_process_target::low_collect_ptrace_register (regcache *regcache,
int regno, char *buf)
{
collect_register (regcache, regno, buf);
}
void
linux_process_target::low_supply_ptrace_register (regcache *regcache,
int regno, const char *buf)
{
supply_register (regcache, regno, buf);
}
gdbserver/linux-low: turn 'cannot_{fetch/store}_register' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'cannot_fetch_register' and 'cannot_store_register' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the low target ops. (class linux_process_target) <fetch_register> <store_register> <usr_fetch_inferior_registers> <usr_store_inferior_registers> <low_cannot_fetch_register> <low_cannot_fetch_register> Declare. * linux-low.cc (fetch_register): Turn into... (linux_process_target::fetch_register): ...this. (store_register): Turn into ... (linux_process_target::store_register): ...this. (usr_fetch_inferior_registers): Turn into... (linux_process_target::usr_fetch_inferior_registers): ...this. (usr_store_inferior_registers): Turn into... (linux_process_target::usr_store_inferior_registers): ...this. * linux-x86-low.cc (class x86_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (x86_cannot_store_register): Turn into... (x86_target::low_cannot_store_register): ...this. (x86_cannot_fetch_register): Turn into... (x86_target::low_cannot_fetch_register): ...this. (the_low_target): Remove the target op fields. * linux-aarch64-low.cc (class aarch64_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (aarch64_target::low_cannot_fetch_register) (aarch64_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (arm_cannot_fetch_register): Turn into... (arm_target::low_cannot_fetch_register): ...this. (arm_cannot_store_register): Turn into... (arm_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (bfin_cannot_fetch_register): Turn into... (bfin_target::low_cannot_fetch_register): ...this. (bfin_cannot_store_register): Turn into... (bfin_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (cris_cannot_fetch_register): Turn into... (cris_target::low_cannot_fetch_register): ...this. (cris_cannot_store_register): Turn into... (cris_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (crisv32_target::low_cannot_fetch_register) (crisv32_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-ia64-low.cc (class ia64_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (ia64_cannot_fetch_register): Turn into... (ia64_target::low_cannot_fetch_register): ...this. (ia64_cannot_store_register): Turn into... (ia64_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (m32r_cannot_fetch_register): Turn into... (m32r_target::low_cannot_fetch_register): ...this. (m32r_cannot_store_register): Turn into... (m32r_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (m68k_cannot_fetch_register): Turn into... (m68k_target::low_cannot_fetch_register): ...this. (m68k_cannot_store_register): Turn into... (m68k_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (mips_cannot_fetch_register): Turn into... (mips_target::low_cannot_fetch_register): ...this. (mips_cannot_store_register): Turn into... (mips_target::low_cannot_store_register): ...this. (get_usrregs_info): Inline at the call sites in low_cannot_fetch_register and low_cannot_store_register, and remove. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (nios2_cannot_fetch_register): Turn into... (nios2_target::low_cannot_fetch_register): ...this. (nios2_cannot_store_register): Turn into... (nios2_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (ppc_cannot_fetch_register): Turn into... (ppc_target::low_cannot_fetch_register): ...this. (ppc_cannot_store_register): Turn into... (ppc_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (riscv_target::low_cannot_fetch_register) (riscv_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (s390_cannot_fetch_register): Turn into... (s390_target::low_cannot_fetch_register): ...this. (s390_cannot_store_register): Turn into... (s390_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (sh_cannot_fetch_register): Turn into... (sh_target::low_cannot_fetch_register): ...this. (sh_cannot_store_register): Turn into... (sh_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (sparc_cannot_fetch_register): Turn into... (sparc_target::low_cannot_fetch_register): ...this. (sparc_cannot_store_register): Turn into... (sparc_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (tic6x_cannot_fetch_register): Turn into... (tic6x_target::low_cannot_fetch_register): ...this. (tic6x_cannot_store_register): Turn into... (tic6x_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (tile_cannot_fetch_register): Turn into... (tile_target::low_cannot_fetch_register): ...this. (tile_cannot_store_register): Turn into... (tile_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (xtensa_target::low_cannot_fetch_register) (xtensa_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
void
linux_process_target::usr_fetch_inferior_registers (const regs_info *regs_info,
regcache *regcache,
int regno, int all)
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
{
gdbserver/linux-low: turn 'cannot_{fetch/store}_register' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'cannot_fetch_register' and 'cannot_store_register' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the low target ops. (class linux_process_target) <fetch_register> <store_register> <usr_fetch_inferior_registers> <usr_store_inferior_registers> <low_cannot_fetch_register> <low_cannot_fetch_register> Declare. * linux-low.cc (fetch_register): Turn into... (linux_process_target::fetch_register): ...this. (store_register): Turn into ... (linux_process_target::store_register): ...this. (usr_fetch_inferior_registers): Turn into... (linux_process_target::usr_fetch_inferior_registers): ...this. (usr_store_inferior_registers): Turn into... (linux_process_target::usr_store_inferior_registers): ...this. * linux-x86-low.cc (class x86_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (x86_cannot_store_register): Turn into... (x86_target::low_cannot_store_register): ...this. (x86_cannot_fetch_register): Turn into... (x86_target::low_cannot_fetch_register): ...this. (the_low_target): Remove the target op fields. * linux-aarch64-low.cc (class aarch64_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (aarch64_target::low_cannot_fetch_register) (aarch64_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (arm_cannot_fetch_register): Turn into... (arm_target::low_cannot_fetch_register): ...this. (arm_cannot_store_register): Turn into... (arm_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (bfin_cannot_fetch_register): Turn into... (bfin_target::low_cannot_fetch_register): ...this. (bfin_cannot_store_register): Turn into... (bfin_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (cris_cannot_fetch_register): Turn into... (cris_target::low_cannot_fetch_register): ...this. (cris_cannot_store_register): Turn into... (cris_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (crisv32_target::low_cannot_fetch_register) (crisv32_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-ia64-low.cc (class ia64_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (ia64_cannot_fetch_register): Turn into... (ia64_target::low_cannot_fetch_register): ...this. (ia64_cannot_store_register): Turn into... (ia64_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (m32r_cannot_fetch_register): Turn into... (m32r_target::low_cannot_fetch_register): ...this. (m32r_cannot_store_register): Turn into... (m32r_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (m68k_cannot_fetch_register): Turn into... (m68k_target::low_cannot_fetch_register): ...this. (m68k_cannot_store_register): Turn into... (m68k_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (mips_cannot_fetch_register): Turn into... (mips_target::low_cannot_fetch_register): ...this. (mips_cannot_store_register): Turn into... (mips_target::low_cannot_store_register): ...this. (get_usrregs_info): Inline at the call sites in low_cannot_fetch_register and low_cannot_store_register, and remove. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (nios2_cannot_fetch_register): Turn into... (nios2_target::low_cannot_fetch_register): ...this. (nios2_cannot_store_register): Turn into... (nios2_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (ppc_cannot_fetch_register): Turn into... (ppc_target::low_cannot_fetch_register): ...this. (ppc_cannot_store_register): Turn into... (ppc_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (riscv_target::low_cannot_fetch_register) (riscv_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (s390_cannot_fetch_register): Turn into... (s390_target::low_cannot_fetch_register): ...this. (s390_cannot_store_register): Turn into... (s390_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (sh_cannot_fetch_register): Turn into... (sh_target::low_cannot_fetch_register): ...this. (sh_cannot_store_register): Turn into... (sh_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (sparc_cannot_fetch_register): Turn into... (sparc_target::low_cannot_fetch_register): ...this. (sparc_cannot_store_register): Turn into... (sparc_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (tic6x_cannot_fetch_register): Turn into... (tic6x_target::low_cannot_fetch_register): ...this. (tic6x_cannot_store_register): Turn into... (tic6x_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (tile_cannot_fetch_register): Turn into... (tile_target::low_cannot_fetch_register): ...this. (tile_cannot_store_register): Turn into... (tile_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (xtensa_target::low_cannot_fetch_register) (xtensa_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
#ifdef HAVE_LINUX_USRREGS
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
struct usrregs_info *usr = regs_info->usrregs;
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
if (regno == -1)
{
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
for (regno = 0; regno < usr->num_regs; regno++)
if (all || !linux_register_in_regsets (regs_info, regno))
fetch_register (usr, regcache, regno);
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
}
else
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
fetch_register (usr, regcache, regno);
gdbserver/linux-low: turn 'cannot_{fetch/store}_register' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'cannot_fetch_register' and 'cannot_store_register' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the low target ops. (class linux_process_target) <fetch_register> <store_register> <usr_fetch_inferior_registers> <usr_store_inferior_registers> <low_cannot_fetch_register> <low_cannot_fetch_register> Declare. * linux-low.cc (fetch_register): Turn into... (linux_process_target::fetch_register): ...this. (store_register): Turn into ... (linux_process_target::store_register): ...this. (usr_fetch_inferior_registers): Turn into... (linux_process_target::usr_fetch_inferior_registers): ...this. (usr_store_inferior_registers): Turn into... (linux_process_target::usr_store_inferior_registers): ...this. * linux-x86-low.cc (class x86_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (x86_cannot_store_register): Turn into... (x86_target::low_cannot_store_register): ...this. (x86_cannot_fetch_register): Turn into... (x86_target::low_cannot_fetch_register): ...this. (the_low_target): Remove the target op fields. * linux-aarch64-low.cc (class aarch64_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (aarch64_target::low_cannot_fetch_register) (aarch64_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (arm_cannot_fetch_register): Turn into... (arm_target::low_cannot_fetch_register): ...this. (arm_cannot_store_register): Turn into... (arm_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (bfin_cannot_fetch_register): Turn into... (bfin_target::low_cannot_fetch_register): ...this. (bfin_cannot_store_register): Turn into... (bfin_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (cris_cannot_fetch_register): Turn into... (cris_target::low_cannot_fetch_register): ...this. (cris_cannot_store_register): Turn into... (cris_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (crisv32_target::low_cannot_fetch_register) (crisv32_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-ia64-low.cc (class ia64_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (ia64_cannot_fetch_register): Turn into... (ia64_target::low_cannot_fetch_register): ...this. (ia64_cannot_store_register): Turn into... (ia64_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (m32r_cannot_fetch_register): Turn into... (m32r_target::low_cannot_fetch_register): ...this. (m32r_cannot_store_register): Turn into... (m32r_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (m68k_cannot_fetch_register): Turn into... (m68k_target::low_cannot_fetch_register): ...this. (m68k_cannot_store_register): Turn into... (m68k_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (mips_cannot_fetch_register): Turn into... (mips_target::low_cannot_fetch_register): ...this. (mips_cannot_store_register): Turn into... (mips_target::low_cannot_store_register): ...this. (get_usrregs_info): Inline at the call sites in low_cannot_fetch_register and low_cannot_store_register, and remove. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (nios2_cannot_fetch_register): Turn into... (nios2_target::low_cannot_fetch_register): ...this. (nios2_cannot_store_register): Turn into... (nios2_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (ppc_cannot_fetch_register): Turn into... (ppc_target::low_cannot_fetch_register): ...this. (ppc_cannot_store_register): Turn into... (ppc_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (riscv_target::low_cannot_fetch_register) (riscv_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (s390_cannot_fetch_register): Turn into... (s390_target::low_cannot_fetch_register): ...this. (s390_cannot_store_register): Turn into... (s390_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (sh_cannot_fetch_register): Turn into... (sh_target::low_cannot_fetch_register): ...this. (sh_cannot_store_register): Turn into... (sh_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (sparc_cannot_fetch_register): Turn into... (sparc_target::low_cannot_fetch_register): ...this. (sparc_cannot_store_register): Turn into... (sparc_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (tic6x_cannot_fetch_register): Turn into... (tic6x_target::low_cannot_fetch_register): ...this. (tic6x_cannot_store_register): Turn into... (tic6x_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (tile_cannot_fetch_register): Turn into... (tile_target::low_cannot_fetch_register): ...this. (tile_cannot_store_register): Turn into... (tile_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (xtensa_target::low_cannot_fetch_register) (xtensa_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
#endif
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
}
gdbserver/linux-low: turn 'cannot_{fetch/store}_register' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'cannot_fetch_register' and 'cannot_store_register' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the low target ops. (class linux_process_target) <fetch_register> <store_register> <usr_fetch_inferior_registers> <usr_store_inferior_registers> <low_cannot_fetch_register> <low_cannot_fetch_register> Declare. * linux-low.cc (fetch_register): Turn into... (linux_process_target::fetch_register): ...this. (store_register): Turn into ... (linux_process_target::store_register): ...this. (usr_fetch_inferior_registers): Turn into... (linux_process_target::usr_fetch_inferior_registers): ...this. (usr_store_inferior_registers): Turn into... (linux_process_target::usr_store_inferior_registers): ...this. * linux-x86-low.cc (class x86_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (x86_cannot_store_register): Turn into... (x86_target::low_cannot_store_register): ...this. (x86_cannot_fetch_register): Turn into... (x86_target::low_cannot_fetch_register): ...this. (the_low_target): Remove the target op fields. * linux-aarch64-low.cc (class aarch64_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (aarch64_target::low_cannot_fetch_register) (aarch64_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (arm_cannot_fetch_register): Turn into... (arm_target::low_cannot_fetch_register): ...this. (arm_cannot_store_register): Turn into... (arm_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (bfin_cannot_fetch_register): Turn into... (bfin_target::low_cannot_fetch_register): ...this. (bfin_cannot_store_register): Turn into... (bfin_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (cris_cannot_fetch_register): Turn into... (cris_target::low_cannot_fetch_register): ...this. (cris_cannot_store_register): Turn into... (cris_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (crisv32_target::low_cannot_fetch_register) (crisv32_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-ia64-low.cc (class ia64_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (ia64_cannot_fetch_register): Turn into... (ia64_target::low_cannot_fetch_register): ...this. (ia64_cannot_store_register): Turn into... (ia64_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (m32r_cannot_fetch_register): Turn into... (m32r_target::low_cannot_fetch_register): ...this. (m32r_cannot_store_register): Turn into... (m32r_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (m68k_cannot_fetch_register): Turn into... (m68k_target::low_cannot_fetch_register): ...this. (m68k_cannot_store_register): Turn into... (m68k_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (mips_cannot_fetch_register): Turn into... (mips_target::low_cannot_fetch_register): ...this. (mips_cannot_store_register): Turn into... (mips_target::low_cannot_store_register): ...this. (get_usrregs_info): Inline at the call sites in low_cannot_fetch_register and low_cannot_store_register, and remove. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (nios2_cannot_fetch_register): Turn into... (nios2_target::low_cannot_fetch_register): ...this. (nios2_cannot_store_register): Turn into... (nios2_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (ppc_cannot_fetch_register): Turn into... (ppc_target::low_cannot_fetch_register): ...this. (ppc_cannot_store_register): Turn into... (ppc_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (riscv_target::low_cannot_fetch_register) (riscv_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (s390_cannot_fetch_register): Turn into... (s390_target::low_cannot_fetch_register): ...this. (s390_cannot_store_register): Turn into... (s390_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (sh_cannot_fetch_register): Turn into... (sh_target::low_cannot_fetch_register): ...this. (sh_cannot_store_register): Turn into... (sh_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (sparc_cannot_fetch_register): Turn into... (sparc_target::low_cannot_fetch_register): ...this. (sparc_cannot_store_register): Turn into... (sparc_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (tic6x_cannot_fetch_register): Turn into... (tic6x_target::low_cannot_fetch_register): ...this. (tic6x_cannot_store_register): Turn into... (tic6x_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (tile_cannot_fetch_register): Turn into... (tile_target::low_cannot_fetch_register): ...this. (tile_cannot_store_register): Turn into... (tile_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (xtensa_target::low_cannot_fetch_register) (xtensa_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
void
linux_process_target::usr_store_inferior_registers (const regs_info *regs_info,
regcache *regcache,
int regno, int all)
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
{
gdbserver/linux-low: turn 'cannot_{fetch/store}_register' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'cannot_fetch_register' and 'cannot_store_register' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the low target ops. (class linux_process_target) <fetch_register> <store_register> <usr_fetch_inferior_registers> <usr_store_inferior_registers> <low_cannot_fetch_register> <low_cannot_fetch_register> Declare. * linux-low.cc (fetch_register): Turn into... (linux_process_target::fetch_register): ...this. (store_register): Turn into ... (linux_process_target::store_register): ...this. (usr_fetch_inferior_registers): Turn into... (linux_process_target::usr_fetch_inferior_registers): ...this. (usr_store_inferior_registers): Turn into... (linux_process_target::usr_store_inferior_registers): ...this. * linux-x86-low.cc (class x86_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (x86_cannot_store_register): Turn into... (x86_target::low_cannot_store_register): ...this. (x86_cannot_fetch_register): Turn into... (x86_target::low_cannot_fetch_register): ...this. (the_low_target): Remove the target op fields. * linux-aarch64-low.cc (class aarch64_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (aarch64_target::low_cannot_fetch_register) (aarch64_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (arm_cannot_fetch_register): Turn into... (arm_target::low_cannot_fetch_register): ...this. (arm_cannot_store_register): Turn into... (arm_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (bfin_cannot_fetch_register): Turn into... (bfin_target::low_cannot_fetch_register): ...this. (bfin_cannot_store_register): Turn into... (bfin_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (cris_cannot_fetch_register): Turn into... (cris_target::low_cannot_fetch_register): ...this. (cris_cannot_store_register): Turn into... (cris_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (crisv32_target::low_cannot_fetch_register) (crisv32_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-ia64-low.cc (class ia64_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (ia64_cannot_fetch_register): Turn into... (ia64_target::low_cannot_fetch_register): ...this. (ia64_cannot_store_register): Turn into... (ia64_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (m32r_cannot_fetch_register): Turn into... (m32r_target::low_cannot_fetch_register): ...this. (m32r_cannot_store_register): Turn into... (m32r_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (m68k_cannot_fetch_register): Turn into... (m68k_target::low_cannot_fetch_register): ...this. (m68k_cannot_store_register): Turn into... (m68k_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (mips_cannot_fetch_register): Turn into... (mips_target::low_cannot_fetch_register): ...this. (mips_cannot_store_register): Turn into... (mips_target::low_cannot_store_register): ...this. (get_usrregs_info): Inline at the call sites in low_cannot_fetch_register and low_cannot_store_register, and remove. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (nios2_cannot_fetch_register): Turn into... (nios2_target::low_cannot_fetch_register): ...this. (nios2_cannot_store_register): Turn into... (nios2_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (ppc_cannot_fetch_register): Turn into... (ppc_target::low_cannot_fetch_register): ...this. (ppc_cannot_store_register): Turn into... (ppc_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (riscv_target::low_cannot_fetch_register) (riscv_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (s390_cannot_fetch_register): Turn into... (s390_target::low_cannot_fetch_register): ...this. (s390_cannot_store_register): Turn into... (s390_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (sh_cannot_fetch_register): Turn into... (sh_target::low_cannot_fetch_register): ...this. (sh_cannot_store_register): Turn into... (sh_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (sparc_cannot_fetch_register): Turn into... (sparc_target::low_cannot_fetch_register): ...this. (sparc_cannot_store_register): Turn into... (sparc_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (tic6x_cannot_fetch_register): Turn into... (tic6x_target::low_cannot_fetch_register): ...this. (tic6x_cannot_store_register): Turn into... (tic6x_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (tile_cannot_fetch_register): Turn into... (tile_target::low_cannot_fetch_register): ...this. (tile_cannot_store_register): Turn into... (tile_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (xtensa_target::low_cannot_fetch_register) (xtensa_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
#ifdef HAVE_LINUX_USRREGS
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
struct usrregs_info *usr = regs_info->usrregs;
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
if (regno == -1)
{
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
for (regno = 0; regno < usr->num_regs; regno++)
if (all || !linux_register_in_regsets (regs_info, regno))
store_register (usr, regcache, regno);
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
}
else
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
store_register (usr, regcache, regno);
#endif
gdbserver/linux-low: turn 'cannot_{fetch/store}_register' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'cannot_fetch_register' and 'cannot_store_register' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the low target ops. (class linux_process_target) <fetch_register> <store_register> <usr_fetch_inferior_registers> <usr_store_inferior_registers> <low_cannot_fetch_register> <low_cannot_fetch_register> Declare. * linux-low.cc (fetch_register): Turn into... (linux_process_target::fetch_register): ...this. (store_register): Turn into ... (linux_process_target::store_register): ...this. (usr_fetch_inferior_registers): Turn into... (linux_process_target::usr_fetch_inferior_registers): ...this. (usr_store_inferior_registers): Turn into... (linux_process_target::usr_store_inferior_registers): ...this. * linux-x86-low.cc (class x86_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (x86_cannot_store_register): Turn into... (x86_target::low_cannot_store_register): ...this. (x86_cannot_fetch_register): Turn into... (x86_target::low_cannot_fetch_register): ...this. (the_low_target): Remove the target op fields. * linux-aarch64-low.cc (class aarch64_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (aarch64_target::low_cannot_fetch_register) (aarch64_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (arm_cannot_fetch_register): Turn into... (arm_target::low_cannot_fetch_register): ...this. (arm_cannot_store_register): Turn into... (arm_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (bfin_cannot_fetch_register): Turn into... (bfin_target::low_cannot_fetch_register): ...this. (bfin_cannot_store_register): Turn into... (bfin_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (cris_cannot_fetch_register): Turn into... (cris_target::low_cannot_fetch_register): ...this. (cris_cannot_store_register): Turn into... (cris_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (crisv32_target::low_cannot_fetch_register) (crisv32_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-ia64-low.cc (class ia64_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (ia64_cannot_fetch_register): Turn into... (ia64_target::low_cannot_fetch_register): ...this. (ia64_cannot_store_register): Turn into... (ia64_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (m32r_cannot_fetch_register): Turn into... (m32r_target::low_cannot_fetch_register): ...this. (m32r_cannot_store_register): Turn into... (m32r_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (m68k_cannot_fetch_register): Turn into... (m68k_target::low_cannot_fetch_register): ...this. (m68k_cannot_store_register): Turn into... (m68k_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (mips_cannot_fetch_register): Turn into... (mips_target::low_cannot_fetch_register): ...this. (mips_cannot_store_register): Turn into... (mips_target::low_cannot_store_register): ...this. (get_usrregs_info): Inline at the call sites in low_cannot_fetch_register and low_cannot_store_register, and remove. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (nios2_cannot_fetch_register): Turn into... (nios2_target::low_cannot_fetch_register): ...this. (nios2_cannot_store_register): Turn into... (nios2_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (ppc_cannot_fetch_register): Turn into... (ppc_target::low_cannot_fetch_register): ...this. (ppc_cannot_store_register): Turn into... (ppc_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (riscv_target::low_cannot_fetch_register) (riscv_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (s390_cannot_fetch_register): Turn into... (s390_target::low_cannot_fetch_register): ...this. (s390_cannot_store_register): Turn into... (s390_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (sh_cannot_fetch_register): Turn into... (sh_target::low_cannot_fetch_register): ...this. (sh_cannot_store_register): Turn into... (sh_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (sparc_cannot_fetch_register): Turn into... (sparc_target::low_cannot_fetch_register): ...this. (sparc_cannot_store_register): Turn into... (sparc_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (tic6x_cannot_fetch_register): Turn into... (tic6x_target::low_cannot_fetch_register): ...this. (tic6x_cannot_store_register): Turn into... (tic6x_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (tile_cannot_fetch_register): Turn into... (tile_target::low_cannot_fetch_register): ...this. (tile_cannot_store_register): Turn into... (tile_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_cannot_fetch_register> <low_cannot_store_register>: Declare. (xtensa_target::low_cannot_fetch_register) (xtensa_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
}
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
gdbserver: turn target ops 'fetch_registers' and 'store_registers' into methods gdbserver/ChangeLog: 2020-02-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn process_stratum_target's fetch_registers and store_registers ops into methods of process_target. * target.h (struct process_stratum_target): Remove the target ops. (class process_target): Add the target ops. (fetch_inferior_registers): Update the macro. (store_inferior_registers): Update the macro. Update the derived classes and callers below. * linux-low.cc (linux_target_ops): Update. (linux_fetch_registers): Turn into ... (linux_process_target::fetch_registers): ... this. (linux_store_registers): Turn into ... (linux_process_target::store_registers): ... this. * linux-low.h (class linux_process_target): Update. * lynx-low.cc (lynx_target_ops): Update. (lynx_fetch_registers): Turn into ... (lynx_process_target::fetch_registers): ... this. (lynx_store_registers): Turn into ... (lynx_process_target::store_registers): ... this. * lynx-low.h (class lynx_process_target): Update. * nto-low.cc (nto_target_ops): Update. (nto_fetch_registers): Turn into ... (nto_process_target::fetch_registers): ... this. (nto_store_registers): Turn into ... (nto_process_target::store_registers): ... this. * nto-low.h (class nto_process_target): Update. * win32-low.cc (win32_target_ops): Update. (win32_fetch_inferior_registers): Turn into ... (win32_process_target::fetch_registers): ... this. (win32_store_inferior_registers): Turn into ... (win32_process_target::store_registers): ... this. * win32-low.h (class win32_process_target): Update.
2020-02-17 16:11:53 +01:00
void
linux_process_target::fetch_registers (regcache *regcache, int regno)
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
{
int use_regsets;
int all = 0;
gdbserver/linux-low: turn 'regs_info' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'regs_info' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops) <regs_info>: Remove. (class linux_process_target) <get_regs_info>: Define. Update the callers below. * linux-low.cc (linux_process_target::fetch_registers) (linux_process_target::store_registers) * proc-service.cc (gregset_info) * linux-x86-low.cc (class x86_target) <get_regs_info>: Declare. (x86_linux_regs_info): Turn into ... (x86_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <get_regs_info>: Declare. (aarch64_regs_info): Turn into ... (aarch64_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (class arm_target) <get_regs_info>: Declare. (arm_regs_info): Turn into ... (arm_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-bfin-low.cc (class bfin_target) <get_regs_info>: Declare. (bfin_regs_info): Turn into ... (bfin_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-cris-low.cc (class cris_target) <get_regs_info>: Declare. (cris_regs_info): Turn into ... (cris_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-crisv32-low.cc (class crisv32_target) <get_regs_info>: Declare. (crisv32_regs_info): Turn into ... (crisv32_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-ia64-low.cc (class ia64_target) <get_regs_info>: Declare. (ia64_regs_info): Turn into ... (ia64_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-m32r-low.cc (class m32r_target) <get_regs_info>: Declare. (m32r_regs_info): Turn into ... (m32r_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-m68k-low.cc (class m68k_target) <get_regs_info>: Declare. (m68k_regs_info): Turn into ... (m68k_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-mips-low.cc (class mips_target) <get_regs_info>: Declare. (mips_regs_info): Turn into ... (mips_target::get_regs_info): ...this. (the_low_target): Remove the op field. (get_usrregs_info): Update the call to the op. * linux-nios2-low.cc (class nios2_target) <get_regs_info>: Declare. (nios2_regs_info): Turn into ... (nios2_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (class ppc_target) <get_regs_info>: Declare. (ppc_regs_info): Turn into ... (ppc_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-riscv-low.cc (class riscv_target) <get_regs_info>: Declare. (riscv_regs_info): Turn into ... (riscv_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-s390-low.cc (class s390_target) <get_regs_info>: Declare. (s390_regs_info): Turn into ... (s390_target::get_regs_info): ...this. (the_low_target): Remove the op field. (s390_collect_ptrace_register) (s390_supply_ptrace_register) (s390_fill_gregset): Update the call to the op. * linux-sh-low.cc (class sh_target) <get_regs_info>: Declare. (sh_regs_info): Turn into ... (sh_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-sparc-low.cc (class sparc_target) <get_regs_info>: Declare. (sparc_regs_info): Turn into ... (sparc_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-tic6x-low.cc (class tic6x_target) <get_regs_info>: Declare. (tic6x_regs_info): Turn into ... (tic6x_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-tile-low.cc (class tile_target) <get_regs_info>: Declare. (tile_regs_info): Turn into ... (tile_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-xtensa-low.cc (class xtensa_target) <get_regs_info>: Declare. (xtensa_regs_info): Turn into ... (xtensa_target::get_regs_info): ...this. (the_low_target): Remove the op field.
2020-04-02 15:11:23 +02:00
const regs_info *regs_info = get_regs_info ();
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
if (regno == -1)
{
gdbserver/linux-low: turn 'fetch_register' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'fetch_register' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops) <fetch_register>: Remove. (class linux_process_target) <low_fetch_register>: Declare. * linux-x86-low.cc (the_low_target) * linux-aarch64-low.cc (the_low_target) * linux-arm-low.cc (the_low_target) * linux-bfin-low.cc (the_low_target) * linux-cris-low.cc (the_low_target) * linux-crisv32-low.cc (the_low_target) * linux-m32r-low.cc (the_low_target) * linux-m68k-low.cc (the_low_target) * linux-nios2-low.cc (the_low_target) * linux-ppc-low.cc (the_low_target) * linux-s390-low.cc (the_low_target) * linux-sh-low.cc (the_low_target) * linux-sparc-low.cc (the_low_target) * linux-tic6x-low.cc (the_low_target) * linux-tile-low.cc (the_low_target) * linux-xtensa-low.cc (the_low_target): Remove the op field. * linux-ia64-low.cc (class ia64_target) <low_fetch_register>: Declare. (ia64_fetch_register): Turn into... (ia64_target::low_fetch_register): ...this. (the_low_target): Remove the op field. * linux-mips-low.cc (class mips_target) <low_fetch_register>: Declare. (mips_fetch_register): Turn into... (mips_target::low_fetch_register): ...this. (the_low_target): Remove the op field. * linux-riscv-low.cc (class riscv_target) <low_fetch_register>: Declare. (riscv_fetch_register): Turn into... (riscv_target::low_fetch_register): ...this. (the_low_target): Remove the op field. Update the callers below. * linux-low.cc (linux_process_target::fetch_registers) (linux_process_target::low_fetch_register)
2020-04-02 15:11:24 +02:00
if (regs_info->usrregs != NULL)
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
for (regno = 0; regno < regs_info->usrregs->num_regs; regno++)
gdbserver/linux-low: turn 'fetch_register' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'fetch_register' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops) <fetch_register>: Remove. (class linux_process_target) <low_fetch_register>: Declare. * linux-x86-low.cc (the_low_target) * linux-aarch64-low.cc (the_low_target) * linux-arm-low.cc (the_low_target) * linux-bfin-low.cc (the_low_target) * linux-cris-low.cc (the_low_target) * linux-crisv32-low.cc (the_low_target) * linux-m32r-low.cc (the_low_target) * linux-m68k-low.cc (the_low_target) * linux-nios2-low.cc (the_low_target) * linux-ppc-low.cc (the_low_target) * linux-s390-low.cc (the_low_target) * linux-sh-low.cc (the_low_target) * linux-sparc-low.cc (the_low_target) * linux-tic6x-low.cc (the_low_target) * linux-tile-low.cc (the_low_target) * linux-xtensa-low.cc (the_low_target): Remove the op field. * linux-ia64-low.cc (class ia64_target) <low_fetch_register>: Declare. (ia64_fetch_register): Turn into... (ia64_target::low_fetch_register): ...this. (the_low_target): Remove the op field. * linux-mips-low.cc (class mips_target) <low_fetch_register>: Declare. (mips_fetch_register): Turn into... (mips_target::low_fetch_register): ...this. (the_low_target): Remove the op field. * linux-riscv-low.cc (class riscv_target) <low_fetch_register>: Declare. (riscv_fetch_register): Turn into... (riscv_target::low_fetch_register): ...this. (the_low_target): Remove the op field. Update the callers below. * linux-low.cc (linux_process_target::fetch_registers) (linux_process_target::low_fetch_register)
2020-04-02 15:11:24 +02:00
low_fetch_register (regcache, regno);
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
all = regsets_fetch_inferior_registers (regs_info->regsets_info, regcache);
if (regs_info->usrregs != NULL)
usr_fetch_inferior_registers (regs_info, regcache, -1, all);
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
}
else
{
gdbserver/linux-low: turn 'fetch_register' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'fetch_register' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops) <fetch_register>: Remove. (class linux_process_target) <low_fetch_register>: Declare. * linux-x86-low.cc (the_low_target) * linux-aarch64-low.cc (the_low_target) * linux-arm-low.cc (the_low_target) * linux-bfin-low.cc (the_low_target) * linux-cris-low.cc (the_low_target) * linux-crisv32-low.cc (the_low_target) * linux-m32r-low.cc (the_low_target) * linux-m68k-low.cc (the_low_target) * linux-nios2-low.cc (the_low_target) * linux-ppc-low.cc (the_low_target) * linux-s390-low.cc (the_low_target) * linux-sh-low.cc (the_low_target) * linux-sparc-low.cc (the_low_target) * linux-tic6x-low.cc (the_low_target) * linux-tile-low.cc (the_low_target) * linux-xtensa-low.cc (the_low_target): Remove the op field. * linux-ia64-low.cc (class ia64_target) <low_fetch_register>: Declare. (ia64_fetch_register): Turn into... (ia64_target::low_fetch_register): ...this. (the_low_target): Remove the op field. * linux-mips-low.cc (class mips_target) <low_fetch_register>: Declare. (mips_fetch_register): Turn into... (mips_target::low_fetch_register): ...this. (the_low_target): Remove the op field. * linux-riscv-low.cc (class riscv_target) <low_fetch_register>: Declare. (riscv_fetch_register): Turn into... (riscv_target::low_fetch_register): ...this. (the_low_target): Remove the op field. Update the callers below. * linux-low.cc (linux_process_target::fetch_registers) (linux_process_target::low_fetch_register)
2020-04-02 15:11:24 +02:00
if (low_fetch_register (regcache, regno))
return;
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
use_regsets = linux_register_in_regsets (regs_info, regno);
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
if (use_regsets)
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
all = regsets_fetch_inferior_registers (regs_info->regsets_info,
regcache);
if ((!use_regsets || all) && regs_info->usrregs != NULL)
usr_fetch_inferior_registers (regs_info, regcache, regno, 1);
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
}
}
gdbserver: turn target ops 'fetch_registers' and 'store_registers' into methods gdbserver/ChangeLog: 2020-02-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn process_stratum_target's fetch_registers and store_registers ops into methods of process_target. * target.h (struct process_stratum_target): Remove the target ops. (class process_target): Add the target ops. (fetch_inferior_registers): Update the macro. (store_inferior_registers): Update the macro. Update the derived classes and callers below. * linux-low.cc (linux_target_ops): Update. (linux_fetch_registers): Turn into ... (linux_process_target::fetch_registers): ... this. (linux_store_registers): Turn into ... (linux_process_target::store_registers): ... this. * linux-low.h (class linux_process_target): Update. * lynx-low.cc (lynx_target_ops): Update. (lynx_fetch_registers): Turn into ... (lynx_process_target::fetch_registers): ... this. (lynx_store_registers): Turn into ... (lynx_process_target::store_registers): ... this. * lynx-low.h (class lynx_process_target): Update. * nto-low.cc (nto_target_ops): Update. (nto_fetch_registers): Turn into ... (nto_process_target::fetch_registers): ... this. (nto_store_registers): Turn into ... (nto_process_target::store_registers): ... this. * nto-low.h (class nto_process_target): Update. * win32-low.cc (win32_target_ops): Update. (win32_fetch_inferior_registers): Turn into ... (win32_process_target::fetch_registers): ... this. (win32_store_inferior_registers): Turn into ... (win32_process_target::store_registers): ... this. * win32-low.h (class win32_process_target): Update.
2020-02-17 16:11:53 +01:00
void
linux_process_target::store_registers (regcache *regcache, int regno)
{
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
int use_regsets;
int all = 0;
gdbserver/linux-low: turn 'regs_info' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'regs_info' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops) <regs_info>: Remove. (class linux_process_target) <get_regs_info>: Define. Update the callers below. * linux-low.cc (linux_process_target::fetch_registers) (linux_process_target::store_registers) * proc-service.cc (gregset_info) * linux-x86-low.cc (class x86_target) <get_regs_info>: Declare. (x86_linux_regs_info): Turn into ... (x86_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <get_regs_info>: Declare. (aarch64_regs_info): Turn into ... (aarch64_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (class arm_target) <get_regs_info>: Declare. (arm_regs_info): Turn into ... (arm_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-bfin-low.cc (class bfin_target) <get_regs_info>: Declare. (bfin_regs_info): Turn into ... (bfin_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-cris-low.cc (class cris_target) <get_regs_info>: Declare. (cris_regs_info): Turn into ... (cris_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-crisv32-low.cc (class crisv32_target) <get_regs_info>: Declare. (crisv32_regs_info): Turn into ... (crisv32_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-ia64-low.cc (class ia64_target) <get_regs_info>: Declare. (ia64_regs_info): Turn into ... (ia64_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-m32r-low.cc (class m32r_target) <get_regs_info>: Declare. (m32r_regs_info): Turn into ... (m32r_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-m68k-low.cc (class m68k_target) <get_regs_info>: Declare. (m68k_regs_info): Turn into ... (m68k_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-mips-low.cc (class mips_target) <get_regs_info>: Declare. (mips_regs_info): Turn into ... (mips_target::get_regs_info): ...this. (the_low_target): Remove the op field. (get_usrregs_info): Update the call to the op. * linux-nios2-low.cc (class nios2_target) <get_regs_info>: Declare. (nios2_regs_info): Turn into ... (nios2_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (class ppc_target) <get_regs_info>: Declare. (ppc_regs_info): Turn into ... (ppc_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-riscv-low.cc (class riscv_target) <get_regs_info>: Declare. (riscv_regs_info): Turn into ... (riscv_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-s390-low.cc (class s390_target) <get_regs_info>: Declare. (s390_regs_info): Turn into ... (s390_target::get_regs_info): ...this. (the_low_target): Remove the op field. (s390_collect_ptrace_register) (s390_supply_ptrace_register) (s390_fill_gregset): Update the call to the op. * linux-sh-low.cc (class sh_target) <get_regs_info>: Declare. (sh_regs_info): Turn into ... (sh_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-sparc-low.cc (class sparc_target) <get_regs_info>: Declare. (sparc_regs_info): Turn into ... (sparc_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-tic6x-low.cc (class tic6x_target) <get_regs_info>: Declare. (tic6x_regs_info): Turn into ... (tic6x_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-tile-low.cc (class tile_target) <get_regs_info>: Declare. (tile_regs_info): Turn into ... (tile_target::get_regs_info): ...this. (the_low_target): Remove the op field. * linux-xtensa-low.cc (class xtensa_target) <get_regs_info>: Declare. (xtensa_regs_info): Turn into ... (xtensa_target::get_regs_info): ...this. (the_low_target): Remove the op field.
2020-04-02 15:11:23 +02:00
const regs_info *regs_info = get_regs_info ();
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
if (regno == -1)
{
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
all = regsets_store_inferior_registers (regs_info->regsets_info,
regcache);
if (regs_info->usrregs != NULL)
usr_store_inferior_registers (regs_info, regcache, regno, all);
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
}
else
{
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
use_regsets = linux_register_in_regsets (regs_info, regno);
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
if (use_regsets)
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
all = regsets_store_inferior_registers (regs_info->regsets_info,
regcache);
if ((!use_regsets || all) && regs_info->usrregs != NULL)
usr_store_inferior_registers (regs_info, regcache, regno, 1);
gdb/ * features/mips-dsp.xml: New file. * features/mips64-dsp.xml: New file. * features/mips-dsp-linux.xml: New file. * features/mips64-dsp-linux.xml: New file. * features/Makefile (WHICH): Add mips-dsp-linux and mips64-dsp-linux. (mips-dsp-expedite, mips64-dsp-expedite): New variables. * features/mips-dsp-linux.c: New file. * features/mips64-dsp-linux.c: New file. * regformats/mips-dsp-linux.dat: New file. * regformats/mips64-dsp-linux.dat: New file. * mips-linux-nat.c (mips_linux_register_addr): Handle DSP registers. (mips64_linux_register_addr): Likewise. (mips64_linux_regsets_fetch_registers): Likewise. (mips64_linux_regsets_store_registers): Likewise. (mips64_linux_fetch_registers): Update call to mips64_linux_regsets_fetch_registers. (mips64_linux_store_registers): Update call to mips64_linux_regsets_store_registers. (mips_linux_read_description): Probe for DSP registers. (_initialize_mips_linux_nat): Call initialize_tdesc_mips_dsp_linux and initialize_tdesc_mips64_dsp_linux. * mips-linux-tdep.c (supply_gregset, mips64_supply_gregset): Remove padding of no longer used embedded register slots. * mips-linux-tdep.h (DSP_BASE, DSP_CONTROL): New macros. (MIPS_RESTART_REGNUM): Redefine enum value. * mips-tdep.c (mips_generic_reg_names): Remove trailing null strings. (mips_tx39_reg_names): Likewise. (mips_linux_reg_names): New array of register names for Linux targets. (mips_register_name): Check for a null pointer in mips_processor_reg_names and return an empty string. (mips_register_type): Exclude embedded registers for the IRIX and Linux ABIs. (mips_pseudo_register_type): Likewise. Use dynamic numbers to refer to FP registers, LO, HI, BadVAddr, Cause and PC. Handle DSP registers. (mips_stab_reg_to_regnum): Handle DSP accumulators. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Likewise. (mips_gdbarch_init): Likewise. Initialize internal register indices for the Linux ABI. Use dynamic numbers to refer to registers, as applicable, while parsing the target description. * mips-tdep.h (struct mips_regnum): Add dspacc/dspctl offsets. gdb/doc/ * gdb.texinfo (MIPS Features): Add org.gnu.gdb.mips.dsp. gdb/gdbserver/ * linux-low.h (linux_target_ops): Add regset_bitmap member. * linux-low.c (use_linux_regsets): New macro. [!HAVE_LINUX_REGSETS] (regsets_fetch_inferior_registers): Likewise. [!HAVE_LINUX_REGSETS] (regsets_store_inferior_registers): Likewise. (linux_register_in_regsets): New function. (usr_fetch_inferior_registers): Skip registers covered by regsets. (usr_store_inferior_registers): Likewise. (usr_fetch_inferior_registers): New macro. (usr_store_inferior_registers): Likewise. (linux_fetch_registers): Handle mixed regset/non-regset targets. (linux_store_registers): Likewise. * linux-mips-low.c (init_registers_mips_dsp_linux): New prototype. (init_registers_mips64_dsp_linux): Likewise. (init_registers_mips_linux): New macro. (init_registers_mips_dsp_linux): Likewise. (mips_dsp_num_regs): Likewise. (DSP_BASE, DSP_CONTROL): New fallback macros. (mips_base_regs): New macro. (mips_regmap): Use it. Fix the size. (mips_dsp_regmap): New variable. (mips_dsp_regset_bitmap): Likewise. (mips_arch_setup): New function. (mips_cannot_fetch_register): Use the_low_target.regmap rather than mips_regmap. (mips_cannot_store_register): Likewise. (the_low_target): Update .arch_setup, .num_regs and .regmap initializers. Add .regset_bitmap initializer. * linux-arm-low.c (the_low_target): Add .regset_bitmap initializer. * linux-bfin-low.c (the_low_target): Likewise. * linux-cris-low.c (the_low_target): Likewise. * linux-crisv32-low.c (the_low_target): Likewise. * linux-ia64-low.c (the_low_target): Likewise. * linux-m32r-low.c (the_low_target): Likewise. * linux-m68k-low.c (the_low_target): Likewise. * linux-ppc-low.c (the_low_target): Likewise. * linux-s390-low.c (the_low_target): Likewise. * linux-sh-low.c (the_low_target): Likewise. * linux-sparc-low.c (the_low_target): Likewise. * linux-tic6x-low.c (the_low_target): Likewise. * linux-x86-low.c (the_low_target): Likewise. * linux-xtensa-low.c (the_low_target): Likewise. * configure.srv <mips*-*-linux*>: Add mips-dsp-linux.o and mips64-dsp-linux.o to srv_regobj. Add mips-dsp-linux.xml, mips64-dsp-linux.xml, mips-dsp.xml and mips64-dsp.xml to srv_xmlfiles. * Makefile.in (mips-dsp-linux.o, mips-dsp-linux.c): New targets. (mips64-dsp-linux.o, mips64-dsp-linux.c): Likewise. gdb/testsuite/ * gdb.xml/tdesc-regs.exp: Add "mips-dsp.xml" to the list of MIPS core registers.
2012-03-01 23:19:48 +01:00
}
}
gdbserver/linux-low: turn 'fetch_register' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'fetch_register' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops) <fetch_register>: Remove. (class linux_process_target) <low_fetch_register>: Declare. * linux-x86-low.cc (the_low_target) * linux-aarch64-low.cc (the_low_target) * linux-arm-low.cc (the_low_target) * linux-bfin-low.cc (the_low_target) * linux-cris-low.cc (the_low_target) * linux-crisv32-low.cc (the_low_target) * linux-m32r-low.cc (the_low_target) * linux-m68k-low.cc (the_low_target) * linux-nios2-low.cc (the_low_target) * linux-ppc-low.cc (the_low_target) * linux-s390-low.cc (the_low_target) * linux-sh-low.cc (the_low_target) * linux-sparc-low.cc (the_low_target) * linux-tic6x-low.cc (the_low_target) * linux-tile-low.cc (the_low_target) * linux-xtensa-low.cc (the_low_target): Remove the op field. * linux-ia64-low.cc (class ia64_target) <low_fetch_register>: Declare. (ia64_fetch_register): Turn into... (ia64_target::low_fetch_register): ...this. (the_low_target): Remove the op field. * linux-mips-low.cc (class mips_target) <low_fetch_register>: Declare. (mips_fetch_register): Turn into... (mips_target::low_fetch_register): ...this. (the_low_target): Remove the op field. * linux-riscv-low.cc (class riscv_target) <low_fetch_register>: Declare. (riscv_fetch_register): Turn into... (riscv_target::low_fetch_register): ...this. (the_low_target): Remove the op field. Update the callers below. * linux-low.cc (linux_process_target::fetch_registers) (linux_process_target::low_fetch_register)
2020-04-02 15:11:24 +02:00
bool
linux_process_target::low_fetch_register (regcache *regcache, int regno)
{
return false;
}
gdbserver: turn target ops 'read_memory' and 'write_memory' into methods gdbserver/ChangeLog: 2020-02-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn process_stratum_target's read_memory and write_memory ops into methods of process_target. * target.h (struct process_stratum_target): Remove the target ops. (class process_target): Add the target ops. Update the derived classes and callers below. * linux-aarch32-low.cc (arm_breakpoint_at): Update. * linux-aarch64-low.cc (aarch64_breakpoint_at): Update. * linux-arm-low.cc (arm_sigreturn_next_pc): Update. (arm_get_syscall_trapinfo): Update. * linux-cris-low.cc (cris_breakpoint_at): Update. * linux-crisv32-low.cc (cris_breakpoint_at): Update. * linux-m32r-low.cc (m32r_breakpoint_at): Update. * linux-mips-low.cc (mips_breakpoint_at): Update. * linux-nios2-low.cc (nios2_breakpoint_at): Update. * linux-ppc-low.cc (ppc_breakpoint_at): Update. * linux-sh-low.cc (sh_breakpoint_at): Update. * linux-sparc-low.cc (sparc_fill_gregset_to_stack): Update. (sparc_store_gregset_from_stack): Update. (sparc_breakpoint_at): Update. * linux-tic6x-low.cc (tic6x_breakpoint_at): Update. * linux-tile-low.cc (tile_breakpoint_at): Update. * linux-x86-low.cc (x86_breakpoint_at): Update. * linux-xtensa-low.cc (xtensa_breakpoint_at): Update. * mem-brea.cc (insert_memory_breakpoint): Update. (validate_inserted_breakpoint): Update. * target.cc (read_inferior_memory): Update. (target_write_memory): Update. * linux-low.cc (linux_target_ops): Update. (linux_read_memory): Make a wrapper around the read_memory target op call. (linux_process_target::read_memory): Rename from linux_read_memory. (linux_write_memory): Turn into ... (linux_process_target::write_memory): ... this. * linux-low.h (class linux_process_target): Update. * lynx-low.cc (lynx_target_ops): Update. (lynx_read_memory): Turn into ... (lynx_process_target::read_memory): ... this. (lynx_write_memory): Turn into ... (lynx_process_target::write_memory): ... this. * lynx-low.h (class lynx_process_target): Update. * nto-low.cc (nto_target_ops): Update. (nto_read_memory): Turn into ... (nto_process_target::read_memory): ... this. (nto_write_memory): Turn into ... (nto_process_target::write_memory): ... this. * nto-low.h (class nto_process_target): Update. * win32-low.cc (win32_target_ops): Update. (win32_read_inferior_memory): Turn into ... (win32_process_target::read_memory): ... this. (win32_write_inferior_memory): Turn into ... (win32_process_target::write_memory): ... this. * win32-low.h (class win32_process_target): Update.
2020-02-17 16:11:53 +01:00
/* A wrapper for the read_memory target op. */
static int
* acconfig.h: Remove. * configure.ac: Add a test for socklen_t. Use three-argument AC_DEFINE throughout. * config.in: Regenerated using autoheader 2.59. * configure: Regenerated. * gdbreplay.c (socklen_t): Provide a default. (remote_open): Use socklen_t. * remote-utils.c (socklen_t): Provide a default. (remote_open): Use socklen_t. (convert_int_to_ascii, convert_ascii_to_int, decode_M_packet): Use unsigned char. * i387-fp.c (struct i387_fsave, struct i387_fxsave): Use unsigned char for buffers. * linux-low.c (linux_read_memory, linux_write_memory) (linux_read_auxv): Likewise. * mem-break.c (breakpoint_data, set_breakpoint_data, check_mem_read) (check_mem_write): Likewise. * mem-break.h (set_breakpoint_data, check_mem_read, check_mem_write): Likewise. * regcache.c (struct inferior_rgcache_data, registers_to_string) (registers_from_string, register_data): Likewise. * server.c (handle_query, main): Likewise. * server.h (convert_ascii_to_int, convert_int_to_ascii) (decode_M_packet): Likewise. * target.c (read_inferior_memory, write_inferior_memory): Likewise. * target.h (struct target_ops): Update read_memory, write_memory, and read_auxv. (read_inferior_memory, write_inferior_memory): Update. * linux-low.h (struct linux_target_ops): Change type of breakpoint to unsigned char *. * linux-arm-low.c, linux-cris-low.c, linux-crisv32-low.c, linux-i386-low.c, linux-m32r-low.c, linux-m68k-low.c, linux-mips-low.c, linux-ppc-low.c, linux-ppc64-low.c, linux-s390-low.c, linux-sh-low.c: Update for changes in read_inferior_memory and the_low_target->breakpoint.
2005-06-13 03:59:22 +02:00
linux_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
gdbserver: turn target ops 'read_memory' and 'write_memory' into methods gdbserver/ChangeLog: 2020-02-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn process_stratum_target's read_memory and write_memory ops into methods of process_target. * target.h (struct process_stratum_target): Remove the target ops. (class process_target): Add the target ops. Update the derived classes and callers below. * linux-aarch32-low.cc (arm_breakpoint_at): Update. * linux-aarch64-low.cc (aarch64_breakpoint_at): Update. * linux-arm-low.cc (arm_sigreturn_next_pc): Update. (arm_get_syscall_trapinfo): Update. * linux-cris-low.cc (cris_breakpoint_at): Update. * linux-crisv32-low.cc (cris_breakpoint_at): Update. * linux-m32r-low.cc (m32r_breakpoint_at): Update. * linux-mips-low.cc (mips_breakpoint_at): Update. * linux-nios2-low.cc (nios2_breakpoint_at): Update. * linux-ppc-low.cc (ppc_breakpoint_at): Update. * linux-sh-low.cc (sh_breakpoint_at): Update. * linux-sparc-low.cc (sparc_fill_gregset_to_stack): Update. (sparc_store_gregset_from_stack): Update. (sparc_breakpoint_at): Update. * linux-tic6x-low.cc (tic6x_breakpoint_at): Update. * linux-tile-low.cc (tile_breakpoint_at): Update. * linux-x86-low.cc (x86_breakpoint_at): Update. * linux-xtensa-low.cc (xtensa_breakpoint_at): Update. * mem-brea.cc (insert_memory_breakpoint): Update. (validate_inserted_breakpoint): Update. * target.cc (read_inferior_memory): Update. (target_write_memory): Update. * linux-low.cc (linux_target_ops): Update. (linux_read_memory): Make a wrapper around the read_memory target op call. (linux_process_target::read_memory): Rename from linux_read_memory. (linux_write_memory): Turn into ... (linux_process_target::write_memory): ... this. * linux-low.h (class linux_process_target): Update. * lynx-low.cc (lynx_target_ops): Update. (lynx_read_memory): Turn into ... (lynx_process_target::read_memory): ... this. (lynx_write_memory): Turn into ... (lynx_process_target::write_memory): ... this. * lynx-low.h (class lynx_process_target): Update. * nto-low.cc (nto_target_ops): Update. (nto_read_memory): Turn into ... (nto_process_target::read_memory): ... this. (nto_write_memory): Turn into ... (nto_process_target::write_memory): ... this. * nto-low.h (class nto_process_target): Update. * win32-low.cc (win32_target_ops): Update. (win32_read_inferior_memory): Turn into ... (win32_process_target::read_memory): ... this. (win32_write_inferior_memory): Turn into ... (win32_process_target::write_memory): ... this. * win32-low.h (class win32_process_target): Update.
2020-02-17 16:11:53 +01:00
{
gdbserver: finish turning the target ops vector into a class Now that 'process_stratum_target' has a single field left, namely 'pt' of type 'process_target', and that all the requests to a 'process_stratum_target' are forwarded to 'pt', meld the 'process_target' class into 'process_stratum_target'. This essentially means 1. All the references of the form 'the_target->pt' become 'the_target'. 2. All the uses of the name 'process_target' become 'process_stratum_target'. 3. The platform-specific target op vectors (e.g. linux_target_ops) are removed and instances of their "process target" classes are used instead. gdbserver/ChangeLog: 2020-02-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * target.h (struct process_stratum_target): Remove. (class process_target): Rename to ... (class process_stratum_target): ... this. * linux-low.h (class linux_process_target): Derive from 'process_stratum_target'. * linux-low.cc (linux_target_ops): Remove. (initialize_low): Set the_target to the singleton instance of linux_process_target. * lynx-low.h (class lynx_process_target): Derive from 'process_stratum_target'. * lynx-low.cc (lynx_target_ops): Remove. (initialize_low): Set the_target to the singleton instance of lynx_process_target. * nto-low.h (class nto_process_target): Derive from 'process_stratum_target'. * nto-low.cc (nto_target_ops): Remove. (initialize_low): Set the_target to the singleton instance of nto_process_target. * win32-low.h (class win32_process_target): Derive from 'process_stratum_target'. * win32-low.cc (win32_target_ops): Remove. (initialize_low): Set the_target to the singleton instance of win32_process_target. Replace 'the_target->pt' with 'the_target' in the uses below. * hostio.cc (hostio_error) (handle_setfs) (handle_open) (handle_unlink) (handle_readlink) * linux-aarch32-low.cc (arm_breakpoint_at) * linux-aarch64-low.cc (aarch64_breakpoint_at) * linux-arm-low.cc (arm_sigreturn_next_pc) (arm_get_hwcap) (arm_get_syscall_trapinfo) * linux-cris-low.cc (cris_breakpoint_at) * linux-crisv32-low.cc (cris_breakpoint_at) * linux-low.cc (handle_extended_wait) (linux_wait_1) (linux_read_memory) (linux_process_target::breakpoint_kind_from_pc) (linux_get_auxv) * linux-m32r-low.cc (m32r_breakpoint_at) * linux-mips-low.cc (mips_breakpoint_at) * linux-nios2-low.cc (nios2_breakpoint_at) * linux-ppc-low.cc (ppc_breakpoint_at) * linux-s390-low.cc (s390_get_hwcap) * linux-sh-low.cc (sh_breakpoint_at) * linux-sparc-low.cc (sparc_fill_gregset_to_stack) (sparc_store_gregset_from_stack) (sparc_breakpoint_at) * linux-tic6x-low.cc (tic6x_breakpoint_at) * linux-tile-low.cc (tile_breakpoint_at) * linux-x86-low.cc (x86_breakpoint_at) * linux-xtensa-low.cc (xtensa_breakpoint_at) * mem-break.cc (bp_size) (bp_opcode) (insert_memory_breakpoint) (set_raw_breakpoint_at) (delete_raw_breakpoint) (z_type_supported) (uninsert_raw_breakpoint) (reinsert_raw_breakpoint) (validate_inserted_breakpoint) * regcache.cc (regcache_read_pc) (regcache_write_pc) * remote-utils.cc (putpkt_binary_1) (input_interrupt) (getpkt) (prepare_resume_reply) * server.cc (handle_general_set) (handle_detach) (handle_qxfer_auxv) (handle_qxfer_exec_file) (handle_qxfer_libraries_svr4) (handle_qxfer_osdata) (handle_qxfer_siginfo) (handle_qxfer_fdpic) (handle_query) (resume) (handle_v_requests) (queue_stop_reply_callback) (captured_main) * target.cc (prepare_to_access_memory) (done_accessing_memory) (read_inferior_memory) (target_write_memory) (target_stop_and_wait) (target_wait) (target_mourn_inferior) (target_continue_no_signal) (target_continue) (target_supports_multi_process) (kill_inferior) * target.h (target_create_inferior) (target_post_create_inferior) (myattach) (target_supports_fork_events) (target_supports_vfork_events) (target_supports_exec_events) (target_handle_new_gdb_connection) (detach_inferior) (mythread_alive) (fetch_inferior_registers) (store_inferior_registers) (join_inferior) (target_supports_non_stop) (target_async) (target_process_qsupported) (target_supports_catch_syscall) (target_get_ipa_tdesc_idx) (target_supports_tracepoints) (target_supports_fast_tracepoints) (target_get_min_fast_tracepoint_insn_len) (target_thread_stopped) (target_pause_all) (target_unpause_all) (target_stabilize_threads) (target_install_fast_tracepoint_jump_pad) (target_emit_ops) (target_supports_disable_randomization) (target_supports_agent) (target_enable_btrace) (target_disable_btrace) (target_read_btrace) (target_read_btrace_conf) (target_supports_range_stepping) (target_supports_stopped_by_sw_breakpoint) (target_stopped_by_sw_breakpoint) (target_supports_stopped_by_hw_breakpoint) (target_supports_hardware_single_step) (target_stopped_by_hw_breakpoint) (target_breakpoint_kind_from_pc) (target_breakpoint_kind_from_current_state) (target_supports_software_single_step) (target_core_of_thread) (target_thread_name) (target_thread_handle) * win32-low.cc (do_initial_child_stuff) Rename target op default definitions listed below. * target.cc (process_target::post_create_inferior): Rename as ... (process_stratum_target::post_create_inferior): ... this. (process_target::prepare_to_access_memory): Rename as ... (process_stratum_target::prepare_to_access_memory): ... this. (process_target::done_accessing_memory): Rename as ... (process_stratum_target::done_accessing_memory): ... this. (process_target::look_up_symbols): Rename as ... (process_stratum_target::look_up_symbols): ... this. (process_target::supports_read_auxv): Rename as ... (process_stratum_target::supports_read_auxv): ... this. (process_target::read_auxv): Rename as ... (process_stratum_target::read_auxv): ... this. (process_target::supports_z_point_type): Rename as ... (process_stratum_target::supports_z_point_type): ... this. (process_target::insert_point): Rename as ... (process_stratum_target::insert_point): ... this. (process_target::remove_point): Rename as ... (process_stratum_target::remove_point): ... this. (process_target::stopped_by_sw_breakpoint): Rename as ... (process_stratum_target::stopped_by_sw_breakpoint): ... this. (process_target::supports_stopped_by_sw_breakpoint): Rename as ... (process_stratum_target::supports_stopped_by_sw_breakpoint): ... this. (process_target::stopped_by_hw_breakpoint): Rename as ... (process_stratum_target::stopped_by_hw_breakpoint): ... this. (process_target::supports_stopped_by_hw_breakpoint): Rename as ... (process_stratum_target::supports_stopped_by_hw_breakpoint): ... this. (process_target::supports_hardware_single_step): Rename as ... (process_stratum_target::supports_hardware_single_step): ... this. (process_target::stopped_by_watchpoint): Rename as ... (process_stratum_target::stopped_by_watchpoint): ... this. (process_target::stopped_data_address): Rename as ... (process_stratum_target::stopped_data_address): ... this. (process_target::supports_read_offsets): Rename as ... (process_stratum_target::supports_read_offsets): ... this. (process_target::read_offsets): Rename as ... (process_stratum_target::read_offsets): ... this. (process_target::supports_get_tls_address): Rename as ... (process_stratum_target::supports_get_tls_address): ... this. (process_target::get_tls_address): Rename as ... (process_stratum_target::get_tls_address): ... this. (process_target::hostio_last_error): Rename as ... (process_stratum_target::hostio_last_error): ... this. (process_target::supports_qxfer_osdata): Rename as ... (process_stratum_target::supports_qxfer_osdata): ... this. (process_target::qxfer_osdata): Rename as ... (process_stratum_target::qxfer_osdata): ... this. (process_target::supports_qxfer_siginfo): Rename as ... (process_stratum_target::supports_qxfer_siginfo): ... this. (process_target::qxfer_siginfo): Rename as ... (process_stratum_target::qxfer_siginfo): ... this. (process_target::supports_non_stop): Rename as ... (process_stratum_target::supports_non_stop): ... this. (process_target::async): Rename as ... (process_stratum_target::async): ... this. (process_target::start_non_stop): Rename as ... (process_stratum_target::start_non_stop): ... this. (process_target::supports_multi_process): Rename as ... (process_stratum_target::supports_multi_process): ... this. (process_target::supports_fork_events): Rename as ... (process_stratum_target::supports_fork_events): ... this. (process_target::supports_vfork_events): Rename as ... (process_stratum_target::supports_vfork_events): ... this. (process_target::supports_exec_events): Rename as ... (process_stratum_target::supports_exec_events): ... this. (process_target::handle_new_gdb_connection): Rename as ... (process_stratum_target::handle_new_gdb_connection): ... this. (process_target::handle_monitor_command): Rename as ... (process_stratum_target::handle_monitor_command): ... this. (process_target::core_of_thread): Rename as ... (process_stratum_target::core_of_thread): ... this. (process_target::supports_read_loadmap): Rename as ... (process_stratum_target::supports_read_loadmap): ... this. (process_target::read_loadmap): Rename as ... (process_stratum_target::read_loadmap): ... this. (process_target::process_qsupported): Rename as ... (process_stratum_target::process_qsupported): ... this. (process_target::supports_tracepoints): Rename as ... (process_stratum_target::supports_tracepoints): ... this. (process_target::read_pc): Rename as ... (process_stratum_target::read_pc): ... this. (process_target::write_pc): Rename as ... (process_stratum_target::write_pc): ... this. (process_target::supports_thread_stopped): Rename as ... (process_stratum_target::supports_thread_stopped): ... this. (process_target::thread_stopped): Rename as ... (process_stratum_target::thread_stopped): ... this. (process_target::supports_get_tib_address): Rename as ... (process_stratum_target::supports_get_tib_address): ... this. (process_target::get_tib_address): Rename as ... (process_stratum_target::get_tib_address): ... this. (process_target::pause_all): Rename as ... (process_stratum_target::pause_all): ... this. (process_target::unpause_all): Rename as ... (process_stratum_target::unpause_all): ... this. (process_target::stabilize_threads): Rename as ... (process_stratum_target::stabilize_threads): ... this. (process_target::supports_fast_tracepoints): Rename as ... (process_stratum_target::supports_fast_tracepoints): ... this. (process_target::get_min_fast_tracepoint_insn_len): Rename as ... (process_stratum_target::get_min_fast_tracepoint_insn_len): ... this. (process_target::emit_ops): Rename as ... (process_stratum_target::emit_ops): ... this. (process_target::supports_disable_randomization): Rename as ... (process_stratum_target::supports_disable_randomization): ... this. (process_target::supports_qxfer_libraries_svr4): Rename as ... (process_stratum_target::supports_qxfer_libraries_svr4): ... this. (process_target::qxfer_libraries_svr4): Rename as ... (process_stratum_target::qxfer_libraries_svr4): ... this. (process_target::supports_agent): Rename as ... (process_stratum_target::supports_agent): ... this. (process_target::enable_btrace): Rename as ... (process_stratum_target::enable_btrace): ... this. (process_target::disable_btrace): Rename as ... (process_stratum_target::disable_btrace): ... this. (process_target::read_btrace): Rename as ... (process_stratum_target::read_btrace): ... this. (process_target::read_btrace_conf): Rename as ... (process_stratum_target::read_btrace_conf): ... this. (process_target::supports_range_stepping): Rename as ... (process_stratum_target::supports_range_stepping): ... this. (process_target::supports_pid_to_exec_file): Rename as ... (process_stratum_target::supports_pid_to_exec_file): ... this. (process_target::pid_to_exec_file): Rename as ... (process_stratum_target::pid_to_exec_file): ... this. (process_target::supports_multifs): Rename as ... (process_stratum_target::supports_multifs): ... this. (process_target::multifs_open): Rename as ... (process_stratum_target::multifs_open): ... this. (process_target::multifs_unlink): Rename as ... (process_stratum_target::multifs_unlink): ... this. (process_target::multifs_readlink): Rename as ... (process_stratum_target::multifs_readlink): ... this. (process_target::breakpoint_kind_from_pc): Rename as ... (process_stratum_target::breakpoint_kind_from_pc): ... this. (process_target::breakpoint_kind_from_current_state): Rename as ... (process_stratum_target::breakpoint_kind_from_current_state): ... this. (process_target::thread_name): Rename as ... (process_stratum_target::thread_name): ... this. (process_target::thread_handle): Rename as ... (process_stratum_target::thread_handle): ... this. (process_target::supports_software_single_step): Rename as ... (process_stratum_target::supports_software_single_step): ... this. (process_target::supports_catch_syscall): Rename as ... (process_stratum_target::supports_catch_syscall): ... this. (process_target::get_ipa_tdesc_idx): Rename as ... (process_stratum_target::get_ipa_tdesc_idx): ... this.
2020-02-17 16:12:04 +01:00
return the_target->read_memory (memaddr, myaddr, len);
gdbserver: turn target ops 'read_memory' and 'write_memory' into methods gdbserver/ChangeLog: 2020-02-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn process_stratum_target's read_memory and write_memory ops into methods of process_target. * target.h (struct process_stratum_target): Remove the target ops. (class process_target): Add the target ops. Update the derived classes and callers below. * linux-aarch32-low.cc (arm_breakpoint_at): Update. * linux-aarch64-low.cc (aarch64_breakpoint_at): Update. * linux-arm-low.cc (arm_sigreturn_next_pc): Update. (arm_get_syscall_trapinfo): Update. * linux-cris-low.cc (cris_breakpoint_at): Update. * linux-crisv32-low.cc (cris_breakpoint_at): Update. * linux-m32r-low.cc (m32r_breakpoint_at): Update. * linux-mips-low.cc (mips_breakpoint_at): Update. * linux-nios2-low.cc (nios2_breakpoint_at): Update. * linux-ppc-low.cc (ppc_breakpoint_at): Update. * linux-sh-low.cc (sh_breakpoint_at): Update. * linux-sparc-low.cc (sparc_fill_gregset_to_stack): Update. (sparc_store_gregset_from_stack): Update. (sparc_breakpoint_at): Update. * linux-tic6x-low.cc (tic6x_breakpoint_at): Update. * linux-tile-low.cc (tile_breakpoint_at): Update. * linux-x86-low.cc (x86_breakpoint_at): Update. * linux-xtensa-low.cc (xtensa_breakpoint_at): Update. * mem-brea.cc (insert_memory_breakpoint): Update. (validate_inserted_breakpoint): Update. * target.cc (read_inferior_memory): Update. (target_write_memory): Update. * linux-low.cc (linux_target_ops): Update. (linux_read_memory): Make a wrapper around the read_memory target op call. (linux_process_target::read_memory): Rename from linux_read_memory. (linux_write_memory): Turn into ... (linux_process_target::write_memory): ... this. * linux-low.h (class linux_process_target): Update. * lynx-low.cc (lynx_target_ops): Update. (lynx_read_memory): Turn into ... (lynx_process_target::read_memory): ... this. (lynx_write_memory): Turn into ... (lynx_process_target::write_memory): ... this. * lynx-low.h (class lynx_process_target): Update. * nto-low.cc (nto_target_ops): Update. (nto_read_memory): Turn into ... (nto_process_target::read_memory): ... this. (nto_write_memory): Turn into ... (nto_process_target::write_memory): ... this. * nto-low.h (class nto_process_target): Update. * win32-low.cc (win32_target_ops): Update. (win32_read_inferior_memory): Turn into ... (win32_process_target::read_memory): ... this. (win32_write_inferior_memory): Turn into ... (win32_process_target::write_memory): ... this. * win32-low.h (class win32_process_target): Update.
2020-02-17 16:11:53 +01:00
}
/* Copy LEN bytes from inferior's memory starting at MEMADDR
to debugger memory starting at MYADDR. */
int
linux_process_target::read_memory (CORE_ADDR memaddr,
unsigned char *myaddr, int len)
{
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
int pid = lwpid_of (current_thread);
PTRACE_XFER_TYPE *buffer;
CORE_ADDR addr;
int count;
char filename[64];
int i;
int ret;
int fd;
/* Try using /proc. Don't bother for one word. */
if (len >= 3 * sizeof (long))
{
int bytes;
/* We could keep this file open and cache it - possibly one per
thread. That requires some juggling, but is even faster. */
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
sprintf (filename, "/proc/%d/mem", pid);
fd = open (filename, O_RDONLY | O_LARGEFILE);
if (fd == -1)
goto no_proc;
/* If pread64 is available, use it. It's faster if the kernel
supports it (only one syscall), and it's 64-bit safe even on
32-bit platforms (for instance, SPARC debugging a SPARC64
application). */
#ifdef HAVE_PREAD64
bytes = pread64 (fd, myaddr, len, memaddr);
#else
bytes = -1;
if (lseek (fd, memaddr, SEEK_SET) != -1)
bytes = read (fd, myaddr, len);
#endif
close (fd);
if (bytes == len)
return 0;
/* Some data was read, we'll try to get the rest with ptrace. */
if (bytes > 0)
{
memaddr += bytes;
myaddr += bytes;
len -= bytes;
}
}
no_proc:
/* Round starting address down to longword boundary. */
addr = memaddr & -(CORE_ADDR) sizeof (PTRACE_XFER_TYPE);
/* Round ending address up; get number of longwords that makes. */
count = ((((memaddr + len) - addr) + sizeof (PTRACE_XFER_TYPE) - 1)
/ sizeof (PTRACE_XFER_TYPE));
/* Allocate buffer of that many longwords. */
Replace some xmalloc-family functions with XNEW-family ones This patch is part of the make-gdb-buildable-in-C++ effort. The idea is to change some calls to the xmalloc family of functions to calls to the equivalents in the XNEW family. This avoids adding an explicit cast, so it keeps the code a bit more readable. Some of them also map relatively well to a C++ equivalent (XNEW (struct foo) -> new foo), so it will be possible to do scripted replacements if needed. I only changed calls that were obviously allocating memory for one or multiple "objects". Allocation of variable sizes (such as strings or buffer handling) will be for later (and won't use XNEW). - xmalloc (sizeof (struct foo)) -> XNEW (struct foo) - xmalloc (num * sizeof (struct foo)) -> XNEWVEC (struct foo, num) - xcalloc (1, sizeof (struct foo)) -> XCNEW (struct foo) - xcalloc (num, sizeof (struct foo)) -> XCNEWVEC (struct foo, num) - xrealloc (p, num * sizeof (struct foo) -> XRESIZEVEC (struct foo, p, num) - obstack_alloc (ob, sizeof (struct foo)) -> XOBNEW (ob, struct foo) - obstack_alloc (ob, num * sizeof (struct foo)) -> XOBNEWVEC (ob, struct foo, num) - alloca (sizeof (struct foo)) -> XALLOCA (struct foo) - alloca (num * sizeof (struct foo)) -> XALLOCAVEC (struct foo, num) Some instances of xmalloc followed by memset to zero the buffer were replaced by XCNEW or XCNEWVEC. I regtested on x86-64, Ubuntu 14.04, but the patch touches many architecture-specific files. For those I'll have to rely on the buildbot or people complaining that I broke their gdb. gdb/ChangeLog: * aarch64-linux-nat.c (aarch64_add_process): Likewise. * aarch64-tdep.c (aarch64_gdbarch_init): Likewise. * ada-exp.y (write_ambiguous_var): Likewise. * ada-lang.c (resolve_subexp): Likewise. (user_select_syms): Likewise. (assign_aggregate): Likewise. (ada_evaluate_subexp): Likewise. (cache_symbol): Likewise. * addrmap.c (allocate_key): Likewise. (addrmap_create_mutable): Likewise. * aix-thread.c (sync_threadlists): Likewise. * alpha-tdep.c (alpha_push_dummy_call): Likewise. (alpha_gdbarch_init): Likewise. * amd64-windows-tdep.c (amd64_windows_push_arguments): Likewise. * arm-linux-nat.c (arm_linux_add_process): Likewise. * arm-linux-tdep.c (arm_linux_displaced_step_copy_insn): Likewise. * arm-tdep.c (push_stack_item): Likewise. (arm_displaced_step_copy_insn): Likewise. (arm_gdbarch_init): Likewise. (_initialize_arm_tdep): Likewise. * avr-tdep.c (push_stack_item): Likewise. * ax-general.c (new_agent_expr): Likewise. * block.c (block_initialize_namespace): Likewise. * breakpoint.c (alloc_counted_command_line): Likewise. (update_dprintf_command_list): Likewise. (parse_breakpoint_sals): Likewise. (decode_static_tracepoint_spec): Likewise. (until_break_command): Likewise. (clear_command): Likewise. (update_global_location_list): Likewise. (get_breakpoint_objfile_data) Likewise. * btrace.c (ftrace_new_function): Likewise. (btrace_set_insn_history): Likewise. (btrace_set_call_history): Likewise. * buildsym.c (add_symbol_to_list): Likewise. (record_pending_block): Likewise. (start_subfile): Likewise. (start_buildsym_compunit): Likewise. (push_subfile): Likewise. (end_symtab_get_static_block): Likewise. (buildsym_init): Likewise. * cli/cli-cmds.c (source_command): Likewise. * cli/cli-decode.c (add_cmd): Likewise. * cli/cli-script.c (build_command_line): Likewise. (setup_user_args): Likewise. (realloc_body_list): Likewise. (process_next_line): Likewise. (copy_command_lines): Likewise. * cli/cli-setshow.c (do_set_command): Likewise. * coff-pe-read.c (read_pe_exported_syms): Likewise. * coffread.c (coff_locate_sections): Likewise. (coff_symtab_read): Likewise. (coff_read_struct_type): Likewise. * common/cleanups.c (make_my_cleanup2): Likewise. * common/common-exceptions.c (throw_it): Likewise. * common/filestuff.c (make_cleanup_close): Likewise. * common/format.c (parse_format_string): Likewise. * common/queue.h (DEFINE_QUEUE_P): Likewise. * compile/compile-object-load.c (munmap_list_add): Likewise. (compile_object_load): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * compile/compile.c (append_args): Likewise. * corefile.c (specify_exec_file_hook): Likewise. * cp-support.c (make_symbol_overload_list): Likewise. * cris-tdep.c (push_stack_item): Likewise. (cris_gdbarch_init): Likewise. * ctf.c (ctf_trace_file_writer_new): Likewise. * dbxread.c (init_header_files): Likewise. (add_new_header_file): Likewise. (init_bincl_list): Likewise. (dbx_end_psymtab): Likewise. (start_psymtab): Likewise. (dbx_end_psymtab): Likewise. * dcache.c (dcache_init): Likewise. * dictionary.c (dict_create_hashed): Likewise. (dict_create_hashed_expandable): Likewise. (dict_create_linear): Likewise. (dict_create_linear_expandable): Likewise. * dtrace-probe.c (dtrace_process_dof_probe): Likewise. * dummy-frame.c (register_dummy_frame_dtor): Likewise. * dwarf2-frame-tailcall.c (cache_new_ref1): Likewise. * dwarf2-frame.c (dwarf2_build_frame_info): Likewise. (decode_frame_entry_1): Likewise. * dwarf2expr.c (new_dwarf_expr_context): Likewise. * dwarf2loc.c (dwarf2_compile_expr_to_ax): Likewise. * dwarf2read.c (dwarf2_has_info): Likewise. (create_signatured_type_table_from_index): Likewise. (dwarf2_read_index): Likewise. (dw2_get_file_names_reader): Likewise. (create_all_type_units): Likewise. (read_cutu_die_from_dwo): Likewise. (init_tu_and_read_dwo_dies): Likewise. (init_cutu_and_read_dies): Likewise. (create_all_comp_units): Likewise. (queue_comp_unit): Likewise. (inherit_abstract_dies): Likewise. (read_call_site_scope): Likewise. (dwarf2_add_field): Likewise. (dwarf2_add_typedef): Likewise. (dwarf2_add_member_fn): Likewise. (attr_to_dynamic_prop): Likewise. (abbrev_table_alloc_abbrev): Likewise. (abbrev_table_read_table): Likewise. (add_include_dir): Likewise. (add_file_name): Likewise. (dwarf_decode_line_header): Likewise. (dwarf2_const_value_attr): Likewise. (dwarf_alloc_block): Likewise. (parse_macro_definition): Likewise. (set_die_type): Likewise. (write_psymtabs_to_index): Likewise. (create_cus_from_index): Likewise. (dwarf2_create_include_psymtab): Likewise. (process_psymtab_comp_unit_reader): Likewise. (build_type_psymtab_dependencies): Likewise. (read_comp_units_from_section): Likewise. (compute_compunit_symtab_includes): Likewise. (create_dwo_unit_in_dwp_v1): Likewise. (create_dwo_unit_in_dwp_v2): Likewise. (read_func_scope): Likewise. (process_structure_scope): Likewise. (mark_common_block_symbol_computed): Likewise. (load_partial_dies): Likewise. (dwarf2_symbol_mark_computed): Likewise. * elfread.c (elf_symfile_segments): Likewise. (elf_read_minimal_symbols): Likewise. * environ.c (make_environ): Likewise. * eval.c (evaluate_subexp_standard): Likewise. * event-loop.c (create_file_handler): Likewise. (create_async_signal_handler): Likewise. (create_async_event_handler): Likewise. (create_timer): Likewise. * exec.c (build_section_table): Likewise. * fbsd-nat.c (fbsd_remember_child): Likewise. * fork-child.c (fork_inferior): Likewise. * frv-tdep.c (new_variant): Likewise. * gdbarch.sh (gdbarch_alloc): Likewise. (append_name): Likewise. * gdbtypes.c (rank_function): Likewise. (copy_type_recursive): Likewise. (add_dyn_prop): Likewise. * gnu-nat.c (make_proc): Likewise. (make_inf): Likewise. (gnu_write_inferior): Likewise. * gnu-v3-abi.c (build_gdb_vtable_type): Likewise. (build_std_type_info_type): Likewise. * guile/scm-param.c (compute_enum_list): Likewise. * guile/scm-utils.c (gdbscm_parse_function_args): Likewise. * guile/scm-value.c (gdbscm_value_call): Likewise. * h8300-tdep.c (h8300_gdbarch_init): Likewise. * hppa-tdep.c (hppa_init_objfile_priv_data): Likewise. (read_unwind_info): Likewise. * ia64-tdep.c (ia64_gdbarch_init): Likewise. * infcall.c (dummy_frame_context_saver_setup): Likewise. (call_function_by_hand_dummy): Likewise. * infcmd.c (step_once): Likewise. (finish_forward): Likewise. (attach_command): Likewise. (notice_new_inferior): Likewise. * inferior.c (add_inferior_silent): Likewise. * infrun.c (add_displaced_stepping_state): Likewise. (save_infcall_control_state): Likewise. (save_inferior_ptid): Likewise. (_initialize_infrun): Likewise. * jit.c (bfd_open_from_target_memory): Likewise. (jit_gdbarch_data_init): Likewise. * language.c (add_language): Likewise. * linespec.c (decode_line_2): Likewise. * linux-nat.c (add_to_pid_list): Likewise. (add_initial_lwp): Likewise. * linux-thread-db.c (add_thread_db_info): Likewise. (record_thread): Likewise. (info_auto_load_libthread_db): Likewise. * m32c-tdep.c (m32c_gdbarch_init): Likewise. * m68hc11-tdep.c (m68hc11_gdbarch_init): Likewise. * m68k-tdep.c (m68k_gdbarch_init): Likewise. * m88k-tdep.c (m88k_analyze_prologue): Likewise. * macrocmd.c (macro_define_command): Likewise. * macroexp.c (gather_arguments): Likewise. * macroscope.c (sal_macro_scope): Likewise. * macrotab.c (new_macro_table): Likewise. * mdebugread.c (push_parse_stack): Likewise. (parse_partial_symbols): Likewise. (parse_symbol): Likewise. (psymtab_to_symtab_1): Likewise. (new_block): Likewise. (new_psymtab): Likewise. (mdebug_build_psymtabs): Likewise. (add_pending): Likewise. (elfmdebug_build_psymtabs): Likewise. * mep-tdep.c (mep_gdbarch_init): Likewise. * mi/mi-main.c (mi_execute_command): Likewise. * mi/mi-parse.c (mi_parse_argv): Likewise. * minidebug.c (lzma_open): Likewise. * minsyms.c (terminate_minimal_symbol_table): Likewise. * mips-linux-nat.c (mips_linux_insert_watchpoint): Likewise. * mips-tdep.c (mips_gdbarch_init): Likewise. * mn10300-tdep.c (mn10300_gdbarch_init): Likewise. * msp430-tdep.c (msp430_gdbarch_init): Likewise. * mt-tdep.c (mt_registers_info): Likewise. * nat/aarch64-linux.c (aarch64_linux_new_thread): Likewise. * nat/linux-btrace.c (linux_enable_bts): Likewise. (linux_enable_pt): Likewise. * nat/linux-osdata.c (linux_xfer_osdata_processes): Likewise. (linux_xfer_osdata_processgroups): Likewise. * nios2-tdep.c (nios2_gdbarch_init): Likewise. * nto-procfs.c (procfs_meminfo): Likewise. * objc-lang.c (start_msglist): Likewise. (selectors_info): Likewise. (classes_info): Likewise. (find_methods): Likewise. * objfiles.c (allocate_objfile): Likewise. (update_section_map): Likewise. * osabi.c (gdbarch_register_osabi): Likewise. (gdbarch_register_osabi_sniffer): Likewise. * parse.c (start_arglist): Likewise. * ppc-linux-nat.c (hwdebug_find_thread_points_by_tid): Likewise. (hwdebug_insert_point): Likewise. * printcmd.c (display_command): Likewise. (ui_printf): Likewise. * procfs.c (create_procinfo): Likewise. (load_syscalls): Likewise. (proc_get_LDT_entry): Likewise. (proc_update_threads): Likewise. * prologue-value.c (make_pv_area): Likewise. (pv_area_store): Likewise. * psymtab.c (extend_psymbol_list): Likewise. (init_psymbol_list): Likewise. (allocate_psymtab): Likewise. * python/py-inferior.c (add_thread_object): Likewise. * python/py-param.c (compute_enum_values): Likewise. * python/py-value.c (valpy_call): Likewise. * python/py-varobj.c (py_varobj_iter_next): Likewise. * python/python.c (ensure_python_env): Likewise. * record-btrace.c (record_btrace_start_replaying): Likewise. * record-full.c (record_full_reg_alloc): Likewise. (record_full_mem_alloc): Likewise. (record_full_end_alloc): Likewise. (record_full_core_xfer_partial): Likewise. * regcache.c (get_thread_arch_aspace_regcache): Likewise. * remote-fileio.c (remote_fileio_init_fd_map): Likewise. * remote-notif.c (remote_notif_state_allocate): Likewise. * remote.c (demand_private_info): Likewise. (remote_notif_stop_alloc_reply): Likewise. (remote_enable_btrace): Likewise. * reverse.c (save_bookmark_command): Likewise. * rl78-tdep.c (rl78_gdbarch_init): Likewise. * rx-tdep.c (rx_gdbarch_init): Likewise. * s390-linux-nat.c (s390_insert_watchpoint): Likewise. * ser-go32.c (dos_get_tty_state): Likewise. (dos_copy_tty_state): Likewise. * ser-mingw.c (ser_windows_open): Likewise. (ser_console_wait_handle): Likewise. (ser_console_get_tty_state): Likewise. (make_pipe_state): Likewise. (net_windows_open): Likewise. * ser-unix.c (hardwire_get_tty_state): Likewise. (hardwire_copy_tty_state): Likewise. * solib-aix.c (solib_aix_new_lm_info): Likewise. * solib-dsbt.c (dsbt_current_sos): Likewise. (dsbt_relocate_main_executable): Likewise. * solib-frv.c (frv_current_sos): Likewise. (frv_relocate_main_executable): Likewise. * solib-spu.c (spu_bfd_fopen): Likewise. * solib-svr4.c (lm_info_read): Likewise. (svr4_copy_library_list): Likewise. (svr4_default_sos): Likewise. * source.c (find_source_lines): Likewise. (line_info): Likewise. (add_substitute_path_rule): Likewise. * spu-linux-nat.c (spu_bfd_open): Likewise. * spu-tdep.c (info_spu_dma_cmdlist): Likewise. * stabsread.c (dbx_lookup_type): Likewise. (read_type): Likewise. (read_member_functions): Likewise. (read_struct_fields): Likewise. (read_baseclasses): Likewise. (read_args): Likewise. (_initialize_stabsread): Likewise. * stack.c (func_command): Likewise. * stap-probe.c (handle_stap_probe): Likewise. * symfile.c (addrs_section_sort): Likewise. (addr_info_make_relative): Likewise. (load_section_callback): Likewise. (add_symbol_file_command): Likewise. (init_filename_language_table): Likewise. * symtab.c (create_filename_seen_cache): Likewise. (sort_search_symbols_remove_dups): Likewise. (search_symbols): Likewise. * target.c (make_cleanup_restore_target_terminal): Likewise. * thread.c (new_thread): Likewise. (enable_thread_stack_temporaries): Likewise. (make_cleanup_restore_current_thread): Likewise. (thread_apply_all_command): Likewise. * tic6x-tdep.c (tic6x_gdbarch_init): Likewise. * top.c (gdb_readline_wrapper): Likewise. * tracefile-tfile.c (tfile_trace_file_writer_new): Likewise. * tracepoint.c (trace_find_line_command): Likewise. (all_tracepoint_actions_and_cleanup): Likewise. (make_cleanup_restore_current_traceframe): Likewise. (get_uploaded_tp): Likewise. (get_uploaded_tsv): Likewise. * tui/tui-data.c (tui_alloc_generic_win_info): Likewise. (tui_alloc_win_info): Likewise. (tui_alloc_content): Likewise. (tui_add_content_elements): Likewise. * tui/tui-disasm.c (tui_find_disassembly_address): Likewise. (tui_set_disassem_content): Likewise. * ui-file.c (ui_file_new): Likewise. (stdio_file_new): Likewise. (tee_file_new): Likewise. * utils.c (make_cleanup_restore_integer): Likewise. (add_internal_problem_command): Likewise. * v850-tdep.c (v850_gdbarch_init): Likewise. * valops.c (find_oload_champ): Likewise. * value.c (allocate_value_lazy): Likewise. (record_latest_value): Likewise. (create_internalvar): Likewise. * varobj.c (install_variable): Likewise. (new_variable): Likewise. (new_root_variable): Likewise. (cppush): Likewise. (_initialize_varobj): Likewise. * windows-nat.c (windows_make_so): Likewise. * x86-nat.c (x86_add_process): Likewise. * xcoffread.c (arrange_linetable): Likewise. (allocate_include_entry): Likewise. (process_linenos): Likewise. (SYMBOL_DUP): Likewise. (xcoff_start_psymtab): Likewise. (xcoff_end_psymtab): Likewise. * xml-support.c (gdb_xml_parse_attr_ulongest): Likewise. * xtensa-tdep.c (xtensa_register_type): Likewise. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. gdb/gdbserver/ChangeLog: * ax.c (gdb_parse_agent_expr): Likewise. (compile_bytecodes): Likewise. * dll.c (loaded_dll): Likewise. * event-loop.c (append_callback_event): Likewise. (create_file_handler): Likewise. (create_file_event): Likewise. * hostio.c (handle_open): Likewise. * inferiors.c (add_thread): Likewise. (add_process): Likewise. * linux-aarch64-low.c (aarch64_linux_new_process): Likewise. * linux-arm-low.c (arm_new_process): Likewise. (arm_new_thread): Likewise. * linux-low.c (add_to_pid_list): Likewise. (linux_add_process): Likewise. (handle_extended_wait): Likewise. (add_lwp): Likewise. (enqueue_one_deferred_signal): Likewise. (enqueue_pending_signal): Likewise. (linux_resume_one_lwp_throw): Likewise. (linux_resume_one_thread): Likewise. (linux_read_memory): Likewise. (linux_write_memory): Likewise. * linux-mips-low.c (mips_linux_new_process): Likewise. (mips_linux_new_thread): Likewise. (mips_add_watchpoint): Likewise. * linux-x86-low.c (initialize_low_arch): Likewise. * lynx-low.c (lynx_add_process): Likewise. * mem-break.c (set_raw_breakpoint_at): Likewise. (set_breakpoint): Likewise. (add_condition_to_breakpoint): Likewise. (add_commands_to_breakpoint): Likewise. (clone_agent_expr): Likewise. (clone_one_breakpoint): Likewise. * regcache.c (new_register_cache): Likewise. * remote-utils.c (look_up_one_symbol): Likewise. * server.c (queue_stop_reply): Likewise. (start_inferior): Likewise. (queue_stop_reply_callback): Likewise. (handle_target_event): Likewise. * spu-low.c (fetch_ppc_memory): Likewise. (store_ppc_memory): Likewise. * target.c (set_target_ops): Likewise. * thread-db.c (thread_db_load_search): Likewise. (try_thread_db_load_1): Likewise. * tracepoint.c (add_tracepoint): Likewise. (add_tracepoint_action): Likewise. (create_trace_state_variable): Likewise. (cmd_qtdpsrc): Likewise. (cmd_qtro): Likewise. (add_while_stepping_state): Likewise. * win32-low.c (child_add_thread): Likewise. (get_image_name): Likewise.
2015-08-26 23:16:07 +02:00
buffer = XALLOCAVEC (PTRACE_XFER_TYPE, count);
/* Read all the longwords */
errno = 0;
for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE))
{
/* Coerce the 3rd arg to a uintptr_t first to avoid potential gcc warning
about coercing an 8 byte integer to a 4 byte pointer. */
buffer[i] = ptrace (PTRACE_PEEKTEXT, pid,
(PTRACE_TYPE_ARG3) (uintptr_t) addr,
(PTRACE_TYPE_ARG4) 0);
if (errno)
break;
}
ret = errno;
/* Copy appropriate bytes out of the buffer. */
if (i > 0)
{
i *= sizeof (PTRACE_XFER_TYPE);
i -= memaddr & (sizeof (PTRACE_XFER_TYPE) - 1);
memcpy (myaddr,
(char *) buffer + (memaddr & (sizeof (PTRACE_XFER_TYPE) - 1)),
i < len ? i : len);
}
return ret;
}
/* Copy LEN bytes of data from debugger memory at MYADDR to inferior's
memory at MEMADDR. On failure (cannot write to the inferior)
returns the value of errno. Always succeeds if LEN is zero. */
gdbserver: turn target ops 'read_memory' and 'write_memory' into methods gdbserver/ChangeLog: 2020-02-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn process_stratum_target's read_memory and write_memory ops into methods of process_target. * target.h (struct process_stratum_target): Remove the target ops. (class process_target): Add the target ops. Update the derived classes and callers below. * linux-aarch32-low.cc (arm_breakpoint_at): Update. * linux-aarch64-low.cc (aarch64_breakpoint_at): Update. * linux-arm-low.cc (arm_sigreturn_next_pc): Update. (arm_get_syscall_trapinfo): Update. * linux-cris-low.cc (cris_breakpoint_at): Update. * linux-crisv32-low.cc (cris_breakpoint_at): Update. * linux-m32r-low.cc (m32r_breakpoint_at): Update. * linux-mips-low.cc (mips_breakpoint_at): Update. * linux-nios2-low.cc (nios2_breakpoint_at): Update. * linux-ppc-low.cc (ppc_breakpoint_at): Update. * linux-sh-low.cc (sh_breakpoint_at): Update. * linux-sparc-low.cc (sparc_fill_gregset_to_stack): Update. (sparc_store_gregset_from_stack): Update. (sparc_breakpoint_at): Update. * linux-tic6x-low.cc (tic6x_breakpoint_at): Update. * linux-tile-low.cc (tile_breakpoint_at): Update. * linux-x86-low.cc (x86_breakpoint_at): Update. * linux-xtensa-low.cc (xtensa_breakpoint_at): Update. * mem-brea.cc (insert_memory_breakpoint): Update. (validate_inserted_breakpoint): Update. * target.cc (read_inferior_memory): Update. (target_write_memory): Update. * linux-low.cc (linux_target_ops): Update. (linux_read_memory): Make a wrapper around the read_memory target op call. (linux_process_target::read_memory): Rename from linux_read_memory. (linux_write_memory): Turn into ... (linux_process_target::write_memory): ... this. * linux-low.h (class linux_process_target): Update. * lynx-low.cc (lynx_target_ops): Update. (lynx_read_memory): Turn into ... (lynx_process_target::read_memory): ... this. (lynx_write_memory): Turn into ... (lynx_process_target::write_memory): ... this. * lynx-low.h (class lynx_process_target): Update. * nto-low.cc (nto_target_ops): Update. (nto_read_memory): Turn into ... (nto_process_target::read_memory): ... this. (nto_write_memory): Turn into ... (nto_process_target::write_memory): ... this. * nto-low.h (class nto_process_target): Update. * win32-low.cc (win32_target_ops): Update. (win32_read_inferior_memory): Turn into ... (win32_process_target::read_memory): ... this. (win32_write_inferior_memory): Turn into ... (win32_process_target::write_memory): ... this. * win32-low.h (class win32_process_target): Update.
2020-02-17 16:11:53 +01:00
int
linux_process_target::write_memory (CORE_ADDR memaddr,
const unsigned char *myaddr, int len)
{
int i;
/* Round starting address down to longword boundary. */
CORE_ADDR addr = memaddr & -(CORE_ADDR) sizeof (PTRACE_XFER_TYPE);
/* Round ending address up; get number of longwords that makes. */
int count
= (((memaddr + len) - addr) + sizeof (PTRACE_XFER_TYPE) - 1)
/ sizeof (PTRACE_XFER_TYPE);
/* Allocate buffer of that many longwords. */
PTRACE_XFER_TYPE *buffer = XALLOCAVEC (PTRACE_XFER_TYPE, count);
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
int pid = lwpid_of (current_thread);
if (len == 0)
{
/* Zero length write always succeeds. */
return 0;
}
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
if (debug_threads)
{
* NEWS: Mention ARM VFP support. * target-descriptions.c (tdesc_register_type): Make public. (tdesc_unnumbered_register): New function. (tdesc_register_reggroup_p): Allow missing pseudo_register_reggroup_p. * target-descriptions.h (tdesc_register_type): Declare. (tdesc_unnumbered_register): Declare. * arm-tdep.c (arm_neon_quad_read, arm_neon_quad_write): New functions. (arm_push_dummy_call): Use arm_neon_quad_write. (arm_neon_double_type, arm_neon_quad_type): New functions. (arm_register_type): Handle VFP and NEON registers. Override the types of double-precision registers for NEON. Disable FPA registers if they are not present. (arm_dwarf_reg_to_regnum): Add current VFP and NEON register numbers. (arm_return_value): Use arm_neon_quad_write and arm_neon_quad_read. (arm_register_name): Handle VFP single and NEON quad registers. (arm_pseudo_read, arm_pseudo_write): New functions. (arm_gdbarch_init): Check for VFP and NEON in the target description. Assign numbers to double-precision registers. Register VFP and NEON pseudo registers. Remove a shadowed "i" variable. * arm-tdep.h (enum gdb_regnum): Add ARM_D0_REGNUM and ARM_D31_REGNUM. (struct gdbarch_tdep): Add have_neon_pseudos, have_neon, have_vfp_registers, have_vfp_pseudos, neon_double_type, and neon_quad_type. * features/Makefile: Make expedite settings only architecture specific. (WHICH): Add new ARM descriptions. * features/arm-with-neon.xml, features/arm-with-vfpv2.c, features/arm-with-vfpv3.c, features/arm-vfpv2.xml, features/arm-vfpv3.xml, features/arm-with-vfpv2.xml, features/arm-with-vfpv3.xml, features/arm-with-neon.c: New files. * regformats/arm-with-neon.dat, regformats/arm-with-vfpv2.dat, regformats/arm-with-vfpv3.dat: Generate. doc/ * gdb.texinfo (ARM Features): Document org.gnu.gdb.arm.vfp and org.gnu.gdb.arm.neon. gdbserver/ * linux-low.c (linux_write_memory): Update debugging output. * Makefile.in (clean): Add new descriptions. (arm-with-vfpv2.o, arm-with-vfpv2.c, arm-with-vfpv3.o) (arm-with-vfpv3.c, arm-with-neon.o, arm-with-neon.c): New rules. * configure.srv: Add new files for arm*-*-linux*. * linux-arm-low.c: Add new declarations. (PTRACE_GETVFPREGS, PTRACE_SETVFPREGS): Define if undefined. (arm_hwcap, HWCAP_VFP, HWCAP_IWMMXT, HWCAP_NEON, HWCAP_VFPv3) (HWCAP_VFPv3D16): New. (arm_fill_wmmxregset, arm_store_wmmxregset): Check HWCAP_IWMMXT instead of __IWMMXT__. (arm_fill_vfpregset, arm_store_vfpregset, arm_get_hwcap) (arm_arch_setup): New. (target_regsets): Remove #ifdef. Add VFP regset. (the_low_target): Use arm_arch_setup. testsuite/ * gdb.base/float.exp: Handle VFP registers.
2009-07-28 20:26:51 +02:00
/* Dump up to four bytes. */
Fix gdbserver --debug issues caught by Valgrind Running gdbserver --debug under Valgrind shows: ==4803== Invalid read of size 4 ==4803== at 0x432B62: linux_write_memory (linux-low.c:5320) ==4803== by 0x4143F7: write_inferior_memory (target.c:83) ==4803== by 0x415895: remove_memory_breakpoint (mem-break.c:362) ==4803== by 0x432EF5: linux_remove_point (linux-low.c:5460) ==4803== by 0x416319: delete_raw_breakpoint (mem-break.c:802) ==4803== by 0x4163F3: release_breakpoint (mem-break.c:842) ==4803== by 0x416477: delete_breakpoint_1 (mem-break.c:869) ==4803== by 0x4164EF: delete_breakpoint (mem-break.c:891) ==4803== by 0x416843: delete_gdb_breakpoint_1 (mem-break.c:1069) ==4803== by 0x4168D8: delete_gdb_breakpoint (mem-break.c:1098) ==4803== by 0x4134E3: process_serial_event (server.c:4051) ==4803== by 0x4138E4: handle_serial_event (server.c:4196) ==4803== Address 0x4c6b930 is 0 bytes inside a block of size 1 alloc'd ==4803== at 0x4A0645D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==4803== by 0x4240C6: xmalloc (common-utils.c:43) ==4803== by 0x41439C: write_inferior_memory (target.c:80) ==4803== by 0x415895: remove_memory_breakpoint (mem-break.c:362) ==4803== by 0x432EF5: linux_remove_point (linux-low.c:5460) ==4803== by 0x416319: delete_raw_breakpoint (mem-break.c:802) ==4803== by 0x4163F3: release_breakpoint (mem-break.c:842) ==4803== by 0x416477: delete_breakpoint_1 (mem-break.c:869) ==4803== by 0x4164EF: delete_breakpoint (mem-break.c:891) ==4803== by 0x416843: delete_gdb_breakpoint_1 (mem-break.c:1069) ==4803== by 0x4168D8: delete_gdb_breakpoint (mem-break.c:1098) ==4803== by 0x4134E3: process_serial_event (server.c:4051) ==4803== And: ==7272== Conditional jump or move depends on uninitialised value(s) ==7272== at 0x3615E48361: vfprintf (vfprintf.c:1634) ==7272== by 0x414E89: debug_vprintf (debug.c:60) ==7272== by 0x42800A: debug_printf (common-debug.c:35) ==7272== by 0x43937B: my_waitpid (linux-waitpid.c:149) ==7272== by 0x42D740: linux_wait_for_event_filtered (linux-low.c:2441) ==7272== by 0x42DADA: linux_wait_for_event (linux-low.c:2552) ==7272== by 0x42E165: linux_wait_1 (linux-low.c:2860) ==7272== by 0x42F5D8: linux_wait (linux-low.c:3453) ==7272== by 0x4144A4: mywait (target.c:107) ==7272== by 0x413969: handle_target_event (server.c:4214) ==7272== by 0x41A1A6: handle_file_event (event-loop.c:429) ==7272== by 0x41996D: process_event (event-loop.c:184) gdb/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * nat/linux-waitpid.c (my_waitpid): Only print *status if waitpid returned > 0. gdb/gdbserver/ChangeLog: 2015-08-06 Pedro Alves <palves@redhat.com> * linux-low.c (linux_write_memory): Rewrite debug output to avoid reading beyond the passed in buffer length.
2015-07-30 17:15:24 +02:00
char str[4 * 2 + 1];
char *p = str;
int dump = len < 4 ? len : 4;
for (i = 0; i < dump; i++)
{
sprintf (p, "%02x", myaddr[i]);
p += 2;
}
*p = '\0';
debug_printf ("Writing %s to 0x%08lx in process %d\n",
str, (long) memaddr, pid);
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
}
/* Fill start and end extra bytes of buffer with existing memory data. */
errno = 0;
/* Coerce the 3rd arg to a uintptr_t first to avoid potential gcc warning
about coercing an 8 byte integer to a 4 byte pointer. */
buffer[0] = ptrace (PTRACE_PEEKTEXT, pid,
(PTRACE_TYPE_ARG3) (uintptr_t) addr,
(PTRACE_TYPE_ARG4) 0);
if (errno)
return errno;
if (count > 1)
{
errno = 0;
buffer[count - 1]
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
= ptrace (PTRACE_PEEKTEXT, pid,
/* Coerce to a uintptr_t first to avoid potential gcc warning
about coercing an 8 byte integer to a 4 byte pointer. */
(PTRACE_TYPE_ARG3) (uintptr_t) (addr + (count - 1)
* sizeof (PTRACE_XFER_TYPE)),
(PTRACE_TYPE_ARG4) 0);
if (errno)
return errno;
}
/* Copy data to be written over corresponding part of buffer. */
memcpy ((char *) buffer + (memaddr & (sizeof (PTRACE_XFER_TYPE) - 1)),
myaddr, len);
/* Write the entire buffer. */
for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE))
{
errno = 0;
ptrace (PTRACE_POKETEXT, pid,
/* Coerce to a uintptr_t first to avoid potential gcc warning
about coercing an 8 byte integer to a 4 byte pointer. */
(PTRACE_TYPE_ARG3) (uintptr_t) addr,
(PTRACE_TYPE_ARG4) buffer[i]);
if (errno)
return errno;
}
return 0;
}
void
linux_process_target::look_up_symbols ()
{
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
#ifdef USE_THREAD_DB
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
struct process_info *proc = current_process ();
if (proc->priv->thread_db != NULL)
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
return;
Remove support for thread events without PTRACE_EVENT_CLONE in GDBServer. This patch removes support for thread events if PTRACE_EVENT_CLONE is not supported in GDBServer. Before, on systems that did not support PTRACE_EVENT_CLONE, both GDB and GDBServer coordinated with libthread_db.so to insert breakpoints at magic locations in libpthread.so, in order to break at thread creation and thread death. Simple software single stepping support was implemented to step over these breakpoints in case there was no hardware single stepping support. However, these simple software single stepping implementations were not fit for any other use as discussed in : https://sourceware.org/ml/gdb-patches/2015-04/msg01110.html These too simple implementations conflict with ongoing work to make proper implementations of software single stepping in GDBServer. The problem is that if some implementations are correct and others are not and only there for the thread magic breakpoint, we can't enable features based solely software single step support since some would be broken. To keep the incorrect implementations and allow the new proper ones at the same time we would need to implement fallback code and it quickly becomes ugly and confusing with multiple checks for legacy software single step or proper software single step. However, PTRACE_EVENT_CLONE was first introduced in Linux 2.5.46, released in November 2002. So I think it's reasonable to just remove support for kernels that don't support PTRACE_EVENT_CLONE, and sidestep the libthread_db breakpoints issues entirely. This thread on the mailling list discusses the issue : https://sourceware.org/ml/gdb/2015-10/msg00078.html No regressions, tested on ubuntu 14.04 ARMv7 and x86. With gdbserver-{native,extended} / { -marm -mthumb } gdb/gdbserver/ChangeLog: * linux-low.c (linux_look_up_symbols): Don't call linux_supports_traceclone. * linux-low.h (thread_db_init): Remove use_events argument. * thread-db.c (thread_db_use_event): Remove global variable. (struct thread_db) <td_thr_event_enable_p>: Remove field. (struct thread_db) <td_create_bp>: Remove field. (thread_db_create_event): Remove function. (thread_db_enable_reporting): Likewise. (find_one_thread): Don't check for thread_db_use_events. (attach_thread): Likewise. (thread_db_load_search): Remove td_thr_event_enable_p initialization. (try_thread_db_load_1): Don't check for thread_db_use_events. (thread_db_init): Remove use_events argument and thread events handling. (remove_thread_event_breakpoints): Remove function. (thread_db_detach): Remove call to remove_thred_event_breakpoints.
2015-11-19 17:29:10 +01:00
thread_db_init ();
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
#endif
}
void
linux_process_target::request_interrupt ()
{
/* Send a SIGINT to the process group. This acts just like the user
typed a ^C on the controlling terminal. */
::kill (-signal_pid, SIGINT);
}
bool
linux_process_target::supports_read_auxv ()
{
return true;
}
/* Copy LEN bytes from inferior's auxiliary vector starting at OFFSET
to debugger memory starting at MYADDR. */
int
linux_process_target::read_auxv (CORE_ADDR offset, unsigned char *myaddr,
unsigned int len)
{
char filename[PATH_MAX];
int fd, n;
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
int pid = lwpid_of (current_thread);
xsnprintf (filename, sizeof filename, "/proc/%d/auxv", pid);
fd = open (filename, O_RDONLY);
if (fd < 0)
return -1;
if (offset != (CORE_ADDR) 0
&& lseek (fd, (off_t) offset, SEEK_SET) != (off_t) offset)
n = -1;
else
n = read (fd, myaddr, len);
close (fd);
return n;
}
int
linux_process_target::insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
int size, raw_breakpoint *bp)
{
gdbserver gnu/linux: stepping over breakpoint Hi, I see the following error on arm linux gdbserver, continue^M Continuing.^M ../../../binutils-gdb/gdb/gdbserver/linux-arm-low.c:458: A problem internal to GDBserver has been detected.^M raw_bkpt_type_to_arm_hwbp_type: unhandled raw type^M Remote connection closed^M (gdb) FAIL: gdb.base/cond-eval-mode.exp: hbreak: continue After we make GDBserver handling Zx/zx packet idempotent, [PATCH 3/3] [GDBserver] Make Zx/zx packet handling idempotent. https://sourceware.org/ml/gdb-patches/2014-04/msg00480.html > Now removal/insertion of all kinds of breakpoints/watchpoints, either > internal, or from GDB, always go through the target methods. GDBserver handles all kinds of breakpoints/watchpoints through target methods. However, some target backends, such as arm, don't support Z0 packet but need software breakpoint to do breakpoint stepping over in linux-low.c:start_step_over, if (can_hardware_single_step ()) { step = 1; } else { CORE_ADDR raddr = (*the_low_target.breakpoint_reinsert_addr) (); set_reinsert_breakpoint (raddr); step = 0; } a software breakpoint is requested to the backend, and the error is triggered. This problem should affect targets having breakpoint_reinsert_addr hooked. Instead of handling memory breakpoint in these affected linux backend, this patch handles memory breakpoint in linux_{insert,remove}_point, that, if memory breakpoint is requested, call {insert,remove}_memory_breakpoint respectively. Then, it becomes unnecessary to handle memory breakpoint for linux x86 backend, so this patch removes the code there. This patch is tested with GDBserver on x86_64-linux and arm-linux (-marm, -mthumb). Note that there are still some fails in gdb.base/cond-eval-mode.exp with -mthumb, because GDBserver doesn't know how to select the correct breakpoint instruction according to the arm-or-thumb-mode of requested address. This is a separate issue, anyway. gdb/gdbserver: 2015-04-09 Yao Qi <yao.qi@linaro.org> * linux-low.c (linux_insert_point): Call insert_memory_breakpoint if TYPE is raw_bkpt_type_sw. (linux_remove_point): Call remove_memory_breakpoint if type is raw_bkpt_type_sw. * linux-x86-low.c (x86_insert_point): Don't call insert_memory_breakpoint. (x86_remove_point): Don't call remove_memory_breakpoint.
2015-04-09 11:20:48 +02:00
if (type == raw_bkpt_type_sw)
return insert_memory_breakpoint (bp);
else
gdbserver/linux-low: turn 'insert_point' and 'remove_point' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'insert_point' and 'remove_point' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <low_insert_point> <low_remove_point>: Declare. * linux-low.cc (linux_process_target::low_insert_point) (linux_process_target::low_remove_point): Define. (linux_process_target::insert_point) (linux_process_target::remove_point): Update for calls to low_insert_point and low_remove_point. * linux-x86-low.cc (class x86_target) <low_insert_point> <low_remove_point>: Declare. (x86_insert_point): Turn into... (x86_target::low_insert_point): ...this. (x86_remove_point): Turn into... (x86_target::low_remove_point): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_insert_point> <low_remove_point>: Declare. (aarch64_insert_point): Turn into... (aarch64_target::low_insert_point): ...this. (aarch64_remove_point): Turn into... (aarch64_target::low_remove_point): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_insert_point> <low_remove_point>: Declare. (arm_insert_point): Turn into... (arm_target::low_insert_point): ...this. (arm_remove_point): Turn into... (arm_target::low_remove_point): ...this. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_insert_point> <low_remove_point>: Declare. (crisv32_insert_point): Turn into... (crisv32_target::low_insert_point): ...this. (crisv32_remove_point): Turn into... (crisv32_target::low_remove_point): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_insert_point> <low_remove_point>: Declare. (mips_insert_point): Turn into... (mips_target::low_insert_point): ...this. (mips_remove_point): Turn into... (mips_target::low_remove_point): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_insert_point> <low_remove_point>: Declare. (ppc_insert_point): Turn into... (ppc_target::low_insert_point): ...this. (ppc_remove_point): Turn into... (ppc_target::low_remove_point): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-sparc-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:27 +02:00
return low_insert_point (type, addr, size, bp);
}
int
linux_process_target::low_insert_point (raw_bkpt_type type, CORE_ADDR addr,
int size, raw_breakpoint *bp)
{
/* Unsupported (see target.h). */
return 1;
}
int
linux_process_target::remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
int size, raw_breakpoint *bp)
{
gdbserver gnu/linux: stepping over breakpoint Hi, I see the following error on arm linux gdbserver, continue^M Continuing.^M ../../../binutils-gdb/gdb/gdbserver/linux-arm-low.c:458: A problem internal to GDBserver has been detected.^M raw_bkpt_type_to_arm_hwbp_type: unhandled raw type^M Remote connection closed^M (gdb) FAIL: gdb.base/cond-eval-mode.exp: hbreak: continue After we make GDBserver handling Zx/zx packet idempotent, [PATCH 3/3] [GDBserver] Make Zx/zx packet handling idempotent. https://sourceware.org/ml/gdb-patches/2014-04/msg00480.html > Now removal/insertion of all kinds of breakpoints/watchpoints, either > internal, or from GDB, always go through the target methods. GDBserver handles all kinds of breakpoints/watchpoints through target methods. However, some target backends, such as arm, don't support Z0 packet but need software breakpoint to do breakpoint stepping over in linux-low.c:start_step_over, if (can_hardware_single_step ()) { step = 1; } else { CORE_ADDR raddr = (*the_low_target.breakpoint_reinsert_addr) (); set_reinsert_breakpoint (raddr); step = 0; } a software breakpoint is requested to the backend, and the error is triggered. This problem should affect targets having breakpoint_reinsert_addr hooked. Instead of handling memory breakpoint in these affected linux backend, this patch handles memory breakpoint in linux_{insert,remove}_point, that, if memory breakpoint is requested, call {insert,remove}_memory_breakpoint respectively. Then, it becomes unnecessary to handle memory breakpoint for linux x86 backend, so this patch removes the code there. This patch is tested with GDBserver on x86_64-linux and arm-linux (-marm, -mthumb). Note that there are still some fails in gdb.base/cond-eval-mode.exp with -mthumb, because GDBserver doesn't know how to select the correct breakpoint instruction according to the arm-or-thumb-mode of requested address. This is a separate issue, anyway. gdb/gdbserver: 2015-04-09 Yao Qi <yao.qi@linaro.org> * linux-low.c (linux_insert_point): Call insert_memory_breakpoint if TYPE is raw_bkpt_type_sw. (linux_remove_point): Call remove_memory_breakpoint if type is raw_bkpt_type_sw. * linux-x86-low.c (x86_insert_point): Don't call insert_memory_breakpoint. (x86_remove_point): Don't call remove_memory_breakpoint.
2015-04-09 11:20:48 +02:00
if (type == raw_bkpt_type_sw)
return remove_memory_breakpoint (bp);
else
gdbserver/linux-low: turn 'insert_point' and 'remove_point' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'insert_point' and 'remove_point' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <low_insert_point> <low_remove_point>: Declare. * linux-low.cc (linux_process_target::low_insert_point) (linux_process_target::low_remove_point): Define. (linux_process_target::insert_point) (linux_process_target::remove_point): Update for calls to low_insert_point and low_remove_point. * linux-x86-low.cc (class x86_target) <low_insert_point> <low_remove_point>: Declare. (x86_insert_point): Turn into... (x86_target::low_insert_point): ...this. (x86_remove_point): Turn into... (x86_target::low_remove_point): ...this. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_insert_point> <low_remove_point>: Declare. (aarch64_insert_point): Turn into... (aarch64_target::low_insert_point): ...this. (aarch64_remove_point): Turn into... (aarch64_target::low_remove_point): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_insert_point> <low_remove_point>: Declare. (arm_insert_point): Turn into... (arm_target::low_insert_point): ...this. (arm_remove_point): Turn into... (arm_target::low_remove_point): ...this. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_insert_point> <low_remove_point>: Declare. (crisv32_insert_point): Turn into... (crisv32_target::low_insert_point): ...this. (crisv32_remove_point): Turn into... (crisv32_target::low_remove_point): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_insert_point> <low_remove_point>: Declare. (mips_insert_point): Turn into... (mips_target::low_insert_point): ...this. (mips_remove_point): Turn into... (mips_target::low_remove_point): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_insert_point> <low_remove_point>: Declare. (ppc_insert_point): Turn into... (ppc_target::low_insert_point): ...this. (ppc_remove_point): Turn into... (ppc_target::low_remove_point): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (the_low_target): Remove the op fields. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-sparc-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto.
2020-04-02 15:11:27 +02:00
return low_remove_point (type, addr, size, bp);
}
int
linux_process_target::low_remove_point (raw_bkpt_type type, CORE_ADDR addr,
int size, raw_breakpoint *bp)
{
/* Unsupported (see target.h). */
return 1;
}
/* Implement the stopped_by_sw_breakpoint target_ops
method. */
bool
linux_process_target::stopped_by_sw_breakpoint ()
{
struct lwp_info *lwp = get_thread_lwp (current_thread);
return (lwp->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT);
}
/* Implement the supports_stopped_by_sw_breakpoint target_ops
method. */
bool
linux_process_target::supports_stopped_by_sw_breakpoint ()
{
return USE_SIGTRAP_SIGINFO;
}
/* Implement the stopped_by_hw_breakpoint target_ops
method. */
bool
linux_process_target::stopped_by_hw_breakpoint ()
{
struct lwp_info *lwp = get_thread_lwp (current_thread);
return (lwp->stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT);
}
/* Implement the supports_stopped_by_hw_breakpoint target_ops
method. */
bool
linux_process_target::supports_stopped_by_hw_breakpoint ()
{
return USE_SIGTRAP_SIGINFO;
}
/* Implement the supports_hardware_single_step target_ops method. */
[gdbserver] Disable conditional breakpoints on no-hardware-single-step targets GDBserver steps over breakpoint if the condition is false, but if target doesn't support hardware single step, the step over is very simple, if not incorrect, in linux-arm-low.c: /* We only place breakpoints in empty marker functions, and thread locking is outside of the function. So rather than importing software single-step, we can just run until exit. */ static CORE_ADDR arm_reinsert_addr (void) { struct regcache *regcache = get_thread_regcache (current_thread, 1); unsigned long pc; collect_register_by_name (regcache, "lr", &pc); return pc; } and linux-mips-low.c does the same. GDBserver sets a breakpoint at the return address of the current function, resume and wait the program hits the breakpoint in order to achieve "breakpoint step over". What if program hits other user breakponits during this "step over"? It is worse if the arm/thumb interworking is considered. Nowadays, GDBserver arm backend unconditionally inserts arm breakpoint, /* Define an ARM-mode breakpoint; we only set breakpoints in the C library, which is most likely to be ARM. If the kernel supports clone events, we will never insert a breakpoint, so even a Thumb C library will work; so will mixing EABI/non-EABI gdbserver and application. */ (const unsigned char *) &arm_breakpoint, (const unsigned char *) &arm_eabi_breakpoint, note that the comments are no longer valid as C library can be compiled in thumb mode. When GDBserver steps over a breakpoint in arm mode function, which returns to thumb mode, GDBserver will insert arm mode breakpoint by mistake and the program will crash. GDBserver alone is unable to determine the arm/thumb mode given a PC address. See how GDB does it in arm-tdep.c:arm_pc_is_thumb. After thinking about how to teach GDBserver inserting right breakpoint (arm or thumb) for a while, I reconsider it from a different direction that it may be unreasonable to run target-side conditional breakpoint for targets without hardware single step. Pedro also pointed this out here https://sourceware.org/ml/gdb-patches/2015-04/msg00337.html This patch is to add a new target_ops hook supports_conditional_breakpoints, and only reply ";ConditionalBreakpoints+" if it is true. On linux targets, supports_conditional_breakpoints returns true if target has hardware single step, on other targets, (win32, lynx, nto, spu), set it to NULL, because conditional breakpoint is a linux-specific feature. gdb/gdbserver: 2015-05-08 Yao Qi <yao.qi@linaro.org> * linux-low.c (linux_supports_conditional_breakpoints): New function. (linux_target_ops): Install new target method. * lynx-low.c (lynx_target_ops): Install NULL hook for supports_conditional_breakpoints. * nto-low.c (nto_target_ops): Likewise. * spu-low.c (spu_target_ops): Likewise. * win32-low.c (win32_target_ops): Likewise. * server.c (handle_query): Check target_supports_conditional_breakpoints. * target.h (struct target_ops) <supports_conditional_breakpoints>: New field. (target_supports_conditional_breakpoints): New macro.
2015-05-08 13:29:13 +02:00
bool
linux_process_target::supports_hardware_single_step ()
[gdbserver] Disable conditional breakpoints on no-hardware-single-step targets GDBserver steps over breakpoint if the condition is false, but if target doesn't support hardware single step, the step over is very simple, if not incorrect, in linux-arm-low.c: /* We only place breakpoints in empty marker functions, and thread locking is outside of the function. So rather than importing software single-step, we can just run until exit. */ static CORE_ADDR arm_reinsert_addr (void) { struct regcache *regcache = get_thread_regcache (current_thread, 1); unsigned long pc; collect_register_by_name (regcache, "lr", &pc); return pc; } and linux-mips-low.c does the same. GDBserver sets a breakpoint at the return address of the current function, resume and wait the program hits the breakpoint in order to achieve "breakpoint step over". What if program hits other user breakponits during this "step over"? It is worse if the arm/thumb interworking is considered. Nowadays, GDBserver arm backend unconditionally inserts arm breakpoint, /* Define an ARM-mode breakpoint; we only set breakpoints in the C library, which is most likely to be ARM. If the kernel supports clone events, we will never insert a breakpoint, so even a Thumb C library will work; so will mixing EABI/non-EABI gdbserver and application. */ (const unsigned char *) &arm_breakpoint, (const unsigned char *) &arm_eabi_breakpoint, note that the comments are no longer valid as C library can be compiled in thumb mode. When GDBserver steps over a breakpoint in arm mode function, which returns to thumb mode, GDBserver will insert arm mode breakpoint by mistake and the program will crash. GDBserver alone is unable to determine the arm/thumb mode given a PC address. See how GDB does it in arm-tdep.c:arm_pc_is_thumb. After thinking about how to teach GDBserver inserting right breakpoint (arm or thumb) for a while, I reconsider it from a different direction that it may be unreasonable to run target-side conditional breakpoint for targets without hardware single step. Pedro also pointed this out here https://sourceware.org/ml/gdb-patches/2015-04/msg00337.html This patch is to add a new target_ops hook supports_conditional_breakpoints, and only reply ";ConditionalBreakpoints+" if it is true. On linux targets, supports_conditional_breakpoints returns true if target has hardware single step, on other targets, (win32, lynx, nto, spu), set it to NULL, because conditional breakpoint is a linux-specific feature. gdb/gdbserver: 2015-05-08 Yao Qi <yao.qi@linaro.org> * linux-low.c (linux_supports_conditional_breakpoints): New function. (linux_target_ops): Install new target method. * lynx-low.c (lynx_target_ops): Install NULL hook for supports_conditional_breakpoints. * nto-low.c (nto_target_ops): Likewise. * spu-low.c (spu_target_ops): Likewise. * win32-low.c (win32_target_ops): Likewise. * server.c (handle_query): Check target_supports_conditional_breakpoints. * target.h (struct target_ops) <supports_conditional_breakpoints>: New field. (target_supports_conditional_breakpoints): New macro.
2015-05-08 13:29:13 +02:00
{
gdbserver/linux-low: turn 'supports_hardware_single_step' into a method All the linux low targets except arm define the 'supports_hardware_single_step' op to return true. Hence, we override the method to return true in linux_process_target, and remove the definitions in all the linux low targets but arm. gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Remove the 'supports_hardware_single_step' linux target op and override the process_stratum_target's op definition in linux_process_target to return true. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <finish_step_over> <maybe_hw_step>: Declare. * linux-low.cc (can_hardware_single_step): Remove. (maybe_hw_step): Turn into... (linux_process_target::maybe_hw_step): ...this. (finish_step_over): Turn into... (linux_process_target::finish_step_over): ...this. (linux_process_target::supports_hardware_single_step): Update to return true. Update the callers below. (linux_process_target::single_step) (linux_process_target::resume_one_lwp_throw) * linux-arm-low.cc (class arm_target) <supports_hardware_single_step>: Declare. (arm_supports_hardware_single_step): Turn into... (arm_target::supports_hardware_single_step): ...this. (the_low_target): Remove the op field. * linux-x86-low.cc (x86_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-aarch64-low.cc (aarch64_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-bfin-low.cc (bfin_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-crisv32-low.cc (cris_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-m32r-low.cc (m32r_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-m68k-low.cc (m68k_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-ppc-low.cc (ppc_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-s390-low.cc (s390_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-sh-low.cc (sh_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-tic6x-low.cc (tic6x_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-tile-low.cc (tile_supports_hardware_single_step): Remove. (the_low_target): Remove the op field. * linux-xtensa-low.cc (xtensa_supports_hardware_single_step): Remove. (the_low_target): Remove the op field.
2020-04-02 15:11:31 +02:00
return true;
[gdbserver] Disable conditional breakpoints on no-hardware-single-step targets GDBserver steps over breakpoint if the condition is false, but if target doesn't support hardware single step, the step over is very simple, if not incorrect, in linux-arm-low.c: /* We only place breakpoints in empty marker functions, and thread locking is outside of the function. So rather than importing software single-step, we can just run until exit. */ static CORE_ADDR arm_reinsert_addr (void) { struct regcache *regcache = get_thread_regcache (current_thread, 1); unsigned long pc; collect_register_by_name (regcache, "lr", &pc); return pc; } and linux-mips-low.c does the same. GDBserver sets a breakpoint at the return address of the current function, resume and wait the program hits the breakpoint in order to achieve "breakpoint step over". What if program hits other user breakponits during this "step over"? It is worse if the arm/thumb interworking is considered. Nowadays, GDBserver arm backend unconditionally inserts arm breakpoint, /* Define an ARM-mode breakpoint; we only set breakpoints in the C library, which is most likely to be ARM. If the kernel supports clone events, we will never insert a breakpoint, so even a Thumb C library will work; so will mixing EABI/non-EABI gdbserver and application. */ (const unsigned char *) &arm_breakpoint, (const unsigned char *) &arm_eabi_breakpoint, note that the comments are no longer valid as C library can be compiled in thumb mode. When GDBserver steps over a breakpoint in arm mode function, which returns to thumb mode, GDBserver will insert arm mode breakpoint by mistake and the program will crash. GDBserver alone is unable to determine the arm/thumb mode given a PC address. See how GDB does it in arm-tdep.c:arm_pc_is_thumb. After thinking about how to teach GDBserver inserting right breakpoint (arm or thumb) for a while, I reconsider it from a different direction that it may be unreasonable to run target-side conditional breakpoint for targets without hardware single step. Pedro also pointed this out here https://sourceware.org/ml/gdb-patches/2015-04/msg00337.html This patch is to add a new target_ops hook supports_conditional_breakpoints, and only reply ";ConditionalBreakpoints+" if it is true. On linux targets, supports_conditional_breakpoints returns true if target has hardware single step, on other targets, (win32, lynx, nto, spu), set it to NULL, because conditional breakpoint is a linux-specific feature. gdb/gdbserver: 2015-05-08 Yao Qi <yao.qi@linaro.org> * linux-low.c (linux_supports_conditional_breakpoints): New function. (linux_target_ops): Install new target method. * lynx-low.c (lynx_target_ops): Install NULL hook for supports_conditional_breakpoints. * nto-low.c (nto_target_ops): Likewise. * spu-low.c (spu_target_ops): Likewise. * win32-low.c (win32_target_ops): Likewise. * server.c (handle_query): Check target_supports_conditional_breakpoints. * target.h (struct target_ops) <supports_conditional_breakpoints>: New field. (target_supports_conditional_breakpoints): New macro.
2015-05-08 13:29:13 +02:00
}
gdbserver: turn target ops 'stopped_by_watchpoint' and 'stopped_data_address' into methods gdbserver/ChangeLog: 2020-02-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn process_stratum_target's stopped_by_watchpoint and stopped_data_address ops into methods of process_target. * target.h (struct process_stratum_target): Remove the target ops. (class process_target): Add the target ops. * target.cc (process_target::stopped_by_watchpoint): Define. (process_target::stopped_data_address): Define. Update the derived classes and callers below. * remote-utils.cc (prepare_resume_reply): Update. * linux-low.cc (linux_target_ops): Update. (linux_stopped_by_watchpoint): Turn into ... (linux_process_target::stopped_by_watchpoint): ... this. (linux_stopped_data_address): Turn into ... (linux_process_target::stopped_data_address): ... this. * linux-low.h (class linux_process_target): Update. * lynx-low.cc (lynx_target_ops): Update. * nto-low.cc (nto_target_ops): Update. (nto_stopped_by_watchpoint): Turn into ... (nto_process_target::stopped_by_watchpoint): ... this. (nto_stopped_data_address): Turn into ... (nto_process_target::stopped_data_address): ... this. * nto-low.h (class nto_process_target): Update. * win32-low.cc (win32_target_ops): Update. (win32_stopped_by_watchpoint): Turn into ... (win32_process_target::stopped_by_watchpoint): ... this. (win32_stopped_data_address): Turn into ... (win32_process_target::stopped_data_address): ... this. * win32-low.h (class win32_process_target): Update.
2020-02-17 16:11:55 +01:00
bool
linux_process_target::stopped_by_watchpoint ()
{
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
struct lwp_info *lwp = get_thread_lwp (current_thread);
return lwp->stop_reason == TARGET_STOPPED_BY_WATCHPOINT;
}
gdbserver: turn target ops 'stopped_by_watchpoint' and 'stopped_data_address' into methods gdbserver/ChangeLog: 2020-02-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn process_stratum_target's stopped_by_watchpoint and stopped_data_address ops into methods of process_target. * target.h (struct process_stratum_target): Remove the target ops. (class process_target): Add the target ops. * target.cc (process_target::stopped_by_watchpoint): Define. (process_target::stopped_data_address): Define. Update the derived classes and callers below. * remote-utils.cc (prepare_resume_reply): Update. * linux-low.cc (linux_target_ops): Update. (linux_stopped_by_watchpoint): Turn into ... (linux_process_target::stopped_by_watchpoint): ... this. (linux_stopped_data_address): Turn into ... (linux_process_target::stopped_data_address): ... this. * linux-low.h (class linux_process_target): Update. * lynx-low.cc (lynx_target_ops): Update. * nto-low.cc (nto_target_ops): Update. (nto_stopped_by_watchpoint): Turn into ... (nto_process_target::stopped_by_watchpoint): ... this. (nto_stopped_data_address): Turn into ... (nto_process_target::stopped_data_address): ... this. * nto-low.h (class nto_process_target): Update. * win32-low.cc (win32_target_ops): Update. (win32_stopped_by_watchpoint): Turn into ... (win32_process_target::stopped_by_watchpoint): ... this. (win32_stopped_data_address): Turn into ... (win32_process_target::stopped_data_address): ... this. * win32-low.h (class win32_process_target): Update.
2020-02-17 16:11:55 +01:00
CORE_ADDR
linux_process_target::stopped_data_address ()
{
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
struct lwp_info *lwp = get_thread_lwp (current_thread);
return lwp->stopped_data_address;
}
/* This is only used for targets that define PT_TEXT_ADDR,
PT_DATA_ADDR and PT_TEXT_END_ADDR. If those are not defined, supposedly
the target has different ways of acquiring this information, like
loadmaps. */
bool
linux_process_target::supports_read_offsets ()
{
#ifdef SUPPORTS_READ_OFFSETS
return true;
#else
return false;
#endif
}
/* Under uClinux, programs are loaded at non-zero offsets, which we need
to tell gdb about. */
int
linux_process_target::read_offsets (CORE_ADDR *text_p, CORE_ADDR *data_p)
{
#ifdef SUPPORTS_READ_OFFSETS
unsigned long text, text_end, data;
int pid = lwpid_of (current_thread);
errno = 0;
text = ptrace (PTRACE_PEEKUSER, pid, (PTRACE_TYPE_ARG3) PT_TEXT_ADDR,
(PTRACE_TYPE_ARG4) 0);
text_end = ptrace (PTRACE_PEEKUSER, pid, (PTRACE_TYPE_ARG3) PT_TEXT_END_ADDR,
(PTRACE_TYPE_ARG4) 0);
data = ptrace (PTRACE_PEEKUSER, pid, (PTRACE_TYPE_ARG3) PT_DATA_ADDR,
(PTRACE_TYPE_ARG4) 0);
if (errno == 0)
{
/* Both text and data offsets produced at compile-time (and so
used by gdb) are relative to the beginning of the program,
with the data segment immediately following the text segment.
However, the actual runtime layout in memory may put the data
somewhere else, so when we send gdb a data base-address, we
use the real data base address and subtract the compile-time
data base-address from it (which is just the length of the
text segment). BSS immediately follows data in both
cases. */
*text_p = text;
*data_p = data - (text_end - text);
return 1;
}
return 0;
#else
gdb_assert_not_reached ("target op read_offsets not supported");
#endif
}
bool
linux_process_target::supports_get_tls_address ()
{
#ifdef USE_THREAD_DB
return true;
#else
return false;
#endif
}
int
linux_process_target::get_tls_address (thread_info *thread,
CORE_ADDR offset,
CORE_ADDR load_module,
CORE_ADDR *address)
{
#ifdef USE_THREAD_DB
return thread_db_get_tls_address (thread, offset, load_module, address);
#else
return -1;
#endif
}
bool
linux_process_target::supports_qxfer_osdata ()
{
return true;
}
int
linux_process_target::qxfer_osdata (const char *annex,
unsigned char *readbuf,
unsigned const char *writebuf,
CORE_ADDR offset, int len)
{
2011-07-22 Kwok Cheung Yeung <kcy@codesourcery.com> gdb/ * defs.h: Add guard against inclusion in gdbserver. (struct ptid, ptid_t): Move to common/ptid.h. (xfree, xzalloc, xasprintf, xvasprintf, xstrprintf, xstrvprintf, xsnprintf, internal_error): Move to common/common-utils.h. (nomem): Delete. * gdb_assert.h: Move into common/ sub-directory. * gdb_locale.h: Ditto. * gdb_dirent.h: Ditto. * inferior.h (minus_one_ptid, null_ptid, ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp, ptid_get_tid, ptid_equal, ptid_is_pid): Move into common/ptid.h. * xml-support.c (xml_escape_text): Move into common/xml-utils.c. (gdb_xml_create_parser_and_cleanup_1, xml_fetch_context_from_file): Change nomem to malloc_failure. * xml-support.h (xml_escape_text): Move into common/xml-utils.h. * utils.c (nomem): Rename to malloc_failure. (xmalloc, xzalloc, xrealloc, xcalloc, xfree, xstrprintf, xasprintf, xvasprintf, xstrvprintf, xsnprintf): Move to common/common-utils.c. (gdb_buildargv): Change nomem to malloc_failure. * infrun.c (null_ptid, minus_one_ptid, ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp, ptid_get_tid, ptid_equal, ptid_is_pid): Move into common/ptid.c. (initialize_infrun): Delete initialization of null_ptid and minus_one_ptid. * linux-nat.c (linux_nat_xfer_osdata): Defer to linux_common_xfer_osdata. * Makefile.in (SFILES): Add common/common-utils.c, common/xml-utils.c, common/ptid.c and common/buffer.c. (HFILES_NO_SRCDIR): Add common/common-utils.h, common/xml-utils.h, common/ptid.h, common/buffer.h and common/linux-osdata.h. (COMMON_OBS): Add xml-utils.o, common-utils.o, buffer.o and ptid.o. (common-utils.o, xml-utils.o, ptid.o, buffer.o, linux-osdata.o): New rules. * common/gdb_assert.h: New. * common/gdb_dirent.h: New. * common/gdb_locale.h: New. * common/buffer.c: New. * common/buffer.h: New. * common/ptid.c: New. * common/ptid.h: New. * common/xml-utils.c: New. * common/xml-utils.h: New. * common/common-utils.c: New. * common/common-utils.h: New. * common/linux-osdata.c: New. * common/linux-osdata.h: New. * config/alpha/alpha-linux.mh (NATDEPFILES): Add linux-osdata.o. * config/arm/linux.mh (NATDEPFILES): Ditto. * config/i386/linux.mh (NATDEPFILES): Ditto. * config/i386/linux64.mh (NATDEPFILES): Ditto. * config/ia64/linux.mh (NATDEPFILES): Ditto. * config/m32r/linux.mh (NATDEPFILES): Ditto. * config/m68k/linux.mh (NATDEPFILES): Ditto. * config/mips/linux.mh (NATDEPFILES): Ditto. * config/pa/linux.mh (NATDEPFILES): Ditto. * config/powerpc/linux.mh (NATDEPFILES): Ditto. * config/powerpc/ppc64-linux.mh (NATDEPFILES): Ditto. * config/s390/s390.mh (NATDEPFILES): Ditto. * config/sparc/linux.mh (NATDEPFILES): Ditto. * config/sparc/linux64.mh (NATDEPFILES): Ditto. * config/xtensa/linux.mh (NATDEPFILES): Ditto. gdbserver/ * linux-low.c (compare_ints, unique, list_threads, show_process, linux_core_of_thread): Delete. (linux_target_ops): Change linux_core_of_thread to linux_common_core_of_thread. (linux_qxfer_osdata): Defer to linux_common_xfer_osdata. * utils.c (malloc_failure): Change type of argument. (xmalloc, xrealloc, xcalloc, xsnprintf): Delete. * Makefile.in (SFILES): Add common/common-utils.c, common/xml-utils.c, common/linux-osdata.c, common/ptid.c and common/buffer.c. (OBS): Add xml-utils.o, common-utils.o, ptid.o and buffer.o. (IPA_OBJS): Add common-utils-ipa.o. (ptid_h, linux_osdata_h): New macros. (server_h): Add common/common-utils.h, common/xml-utils.h, common/buffer.h, common/gdb_assert.h, common/gdb_locale.h and common/ptid.h. (common-utils-ipa.o, common-utils.o, xml-utils.o, linux-osdata.o, ptid.o, buffer.o): New rules. (linux-low.o): Add common/linux-osdata.h as a dependency. * configure.srv (srv_tgtobj): Add linux-osdata.o to Linux targets. * configure.ac: Add AC_HEADER_DIRENT check. * config.in: Regenerate. * configure: Regenerate. * remote-utils.c (xml_escape_text): Delete. (buffer_grow, buffer_free, buffer_init, buffer_finish, buffer_xml_printf): Move to common/buffer.c. * server.c (main): Remove call to initialize_inferiors. * server.h (struct ptid, ptid_t, minus_one_ptid, null_ptid, ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp, ptid_get_tid, ptid_equal, ptid_is_pid, initialize_inferiors, xml_escape_text, internal_error, gdb_assert, gdb_assert_fail): Delete. (struct buffer, buffer_grow, buffer_free, buffer_init, buffer_finish, buffer_xml_printf, buffer_grow_str, buffer_grow_str0): Move to common/buffer.h. * inferiors.c (null_ptid, minus_one_ptid, ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp, ptid_get_tid, ptid_equal, ptid_is_pid, initialize_inferiors): Delete.
2011-07-22 01:46:12 +02:00
return linux_common_xfer_osdata (annex, readbuf, offset, len);
}
void
linux_process_target::siginfo_fixup (siginfo_t *siginfo,
gdb_byte *inf_siginfo, int direction)
{
bool done = low_siginfo_fixup (siginfo, inf_siginfo, direction);
/* If there was no callback, or the callback didn't do anything,
then just do a straight memcpy. */
if (!done)
{
if (direction == 1)
memcpy (siginfo, inf_siginfo, sizeof (siginfo_t));
else
memcpy (inf_siginfo, siginfo, sizeof (siginfo_t));
}
}
bool
linux_process_target::low_siginfo_fixup (siginfo_t *native, gdb_byte *inf,
int direction)
{
return false;
}
bool
linux_process_target::supports_qxfer_siginfo ()
{
return true;
}
int
linux_process_target::qxfer_siginfo (const char *annex,
unsigned char *readbuf,
unsigned const char *writebuf,
CORE_ADDR offset, int len)
2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/ * target.h (enum target_object): Add new TARGET_OBJECT_SIGNAL_INFO. * infrun.c (siginfo_value_read, siginfo_value_write): New. (siginfo_value_funcs): New. (siginfo_make_value): New. (_initialize_infrun): Create the $_siginfo convenience variable. * gdbtypes.h (append_composite_type_field_aligned): Declare. * gdbtypes.c (append_composite_type_field): Rename to... (append_composite_type_field_aligned): ... this. Add ALIGNMENT argument. Handle it. (append_composite_type_field): Rewrite on top of append_composite_type_field_aligned. * value.h (internalvar_make_value): New typedef. (struct internalvar) <make_value>: New field. (create_internalvar_type_lazy): Declare. * value.c (create_internalvar): Clear make_value. (create_internalvar_type_lazy): New. (value_of_internalvar): If make_value is set use it. (preserve_values): Skip internal variables that don't have a value. * gdbarch.sh (get_siginfo_type): New. * gdbarch.h, gdbarch.c: Regenerate. * linux-tdep.h, linux-tdep.c: New. * amd64-linux-tdep.c: Include "linux-tdep.h". (amd64_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * i386-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * arm-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * linux-nat.c (linux_xfer_siginfo): New. (linux_nat_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. * remote.c (PACKET_qXfer_siginfo_read) (PACKET_qXfer_siginfo_write): New. (feature remote_protocol_features): Add "qXfer:siginfo:read" and "qXfer:siginfo:write" features. (remote_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. (_initialize_remote): Add "set/show remote read-siginfo-object" and "set/show remote write-siginfo-object" commands. * Makefile.in (ALL_TARGET_OBS): Add linux-tdep.o. (HFILES_NO_SRCDIR): Add linux-tdep.h. (ALLDEPFILES): Add linux-tdep.c. * configure.tgt (arm*-*-linux* | arm*-*-uclinux*) (i[34567]86-*-linux*, x86_64-*-linux*): Add linux-tdep.o to gdb_target_obs. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/gdbserver/ * server.c (handle_query): Report qXfer:siginfo:read and qXfer:siginfo:write as supported and handle them. * target.h (struct target_ops) <qxfer_siginfo>: New field. * linux-low.c (linux_xfer_siginfo): New. (linux_target_ops): Set it. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/doc/ * gdb.texinfo (Signals): Document $_siginfo. (Convenience Variables): Mention $_siginfo. (Remote Configuration): Document qXfer:siginfo:read, qXfer:siginfo:write packets, and the read-siginfo-object, write-siginfo-object commands. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/testsuite/ * gdb.base/siginfo-obj.c, gdb.base/siginfo-obj.exp: New.
2009-02-06 23:59:01 +01:00
{
int pid;
siginfo_t siginfo;
Fix siginfo C++ build error Change the signature of gdbserver's siginfo_fixup functions so that it's in line with gdb's. This gets rid of the following build error in C++: /home/emaisin/src/binutils-gdb/gdb/gdbserver/linux-x86-low.c: In function ‘int x86_siginfo_fixup(siginfo_t*, void*, int)’: /home/emaisin/src/binutils-gdb/gdb/gdbserver/linux-x86-low.c:694:21: error: invalid conversion from ‘void*’ to ‘gdb_byte* {aka unsigned char*}’ [-fpermissive] FIXUP_32); ^ In file included from /home/emaisin/src/binutils-gdb/gdb/gdbserver/linux-x86-low.c:31:0: /home/emaisin/src/binutils-gdb/gdb/gdbserver/../nat/amd64-linux-siginfo.h:52:5: error: initializing argument 2 of ‘int amd64_linux_siginfo_fixup_common(siginfo_t*, gdb_byte*, int, amd64_siginfo_fixup_mode)’ [-fpermissive] int amd64_linux_siginfo_fixup_common (siginfo_t *native, gdb_byte *inf, ^ /home/emaisin/src/binutils-gdb/gdb/gdbserver/linux-x86-low.c:698:20: error: invalid conversion from ‘void*’ to ‘gdb_byte* {aka unsigned char*}’ [-fpermissive] FIXUP_X32); ^ In file included from /home/emaisin/src/binutils-gdb/gdb/gdbserver/linux-x86-low.c:31:0: /home/emaisin/src/binutils-gdb/gdb/gdbserver/../nat/amd64-linux-siginfo.h:52:5: error: initializing argument 2 of ‘int amd64_linux_siginfo_fixup_common(siginfo_t*, gdb_byte*, int, amd64_siginfo_fixup_mode)’ [-fpermissive] int amd64_linux_siginfo_fixup_common (siginfo_t *native, gdb_byte *inf, ^ gdb/gdbserver/ChangeLog: * linux-aarch64-low.c (aarch64_linux_siginfo_fixup): Change void * to gdb_byte *. * linux-low.c (siginfo_fixup): Likewise. (linux_xfer_siginfo): Likewise. * linux-low.h (struct linux_target_ops) <siginfo_fixup>: Likewise. * linux-x86-low.c (x86_siginfo_fixup): Likewise.
2016-02-09 12:18:15 +01:00
gdb_byte inf_siginfo[sizeof (siginfo_t)];
2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/ * target.h (enum target_object): Add new TARGET_OBJECT_SIGNAL_INFO. * infrun.c (siginfo_value_read, siginfo_value_write): New. (siginfo_value_funcs): New. (siginfo_make_value): New. (_initialize_infrun): Create the $_siginfo convenience variable. * gdbtypes.h (append_composite_type_field_aligned): Declare. * gdbtypes.c (append_composite_type_field): Rename to... (append_composite_type_field_aligned): ... this. Add ALIGNMENT argument. Handle it. (append_composite_type_field): Rewrite on top of append_composite_type_field_aligned. * value.h (internalvar_make_value): New typedef. (struct internalvar) <make_value>: New field. (create_internalvar_type_lazy): Declare. * value.c (create_internalvar): Clear make_value. (create_internalvar_type_lazy): New. (value_of_internalvar): If make_value is set use it. (preserve_values): Skip internal variables that don't have a value. * gdbarch.sh (get_siginfo_type): New. * gdbarch.h, gdbarch.c: Regenerate. * linux-tdep.h, linux-tdep.c: New. * amd64-linux-tdep.c: Include "linux-tdep.h". (amd64_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * i386-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * arm-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * linux-nat.c (linux_xfer_siginfo): New. (linux_nat_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. * remote.c (PACKET_qXfer_siginfo_read) (PACKET_qXfer_siginfo_write): New. (feature remote_protocol_features): Add "qXfer:siginfo:read" and "qXfer:siginfo:write" features. (remote_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. (_initialize_remote): Add "set/show remote read-siginfo-object" and "set/show remote write-siginfo-object" commands. * Makefile.in (ALL_TARGET_OBS): Add linux-tdep.o. (HFILES_NO_SRCDIR): Add linux-tdep.h. (ALLDEPFILES): Add linux-tdep.c. * configure.tgt (arm*-*-linux* | arm*-*-uclinux*) (i[34567]86-*-linux*, x86_64-*-linux*): Add linux-tdep.o to gdb_target_obs. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/gdbserver/ * server.c (handle_query): Report qXfer:siginfo:read and qXfer:siginfo:write as supported and handle them. * target.h (struct target_ops) <qxfer_siginfo>: New field. * linux-low.c (linux_xfer_siginfo): New. (linux_target_ops): Set it. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/doc/ * gdb.texinfo (Signals): Document $_siginfo. (Convenience Variables): Mention $_siginfo. (Remote Configuration): Document qXfer:siginfo:read, qXfer:siginfo:write packets, and the read-siginfo-object, write-siginfo-object commands. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/testsuite/ * gdb.base/siginfo-obj.c, gdb.base/siginfo-obj.exp: New.
2009-02-06 23:59:01 +01:00
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
if (current_thread == NULL)
2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/ * target.h (enum target_object): Add new TARGET_OBJECT_SIGNAL_INFO. * infrun.c (siginfo_value_read, siginfo_value_write): New. (siginfo_value_funcs): New. (siginfo_make_value): New. (_initialize_infrun): Create the $_siginfo convenience variable. * gdbtypes.h (append_composite_type_field_aligned): Declare. * gdbtypes.c (append_composite_type_field): Rename to... (append_composite_type_field_aligned): ... this. Add ALIGNMENT argument. Handle it. (append_composite_type_field): Rewrite on top of append_composite_type_field_aligned. * value.h (internalvar_make_value): New typedef. (struct internalvar) <make_value>: New field. (create_internalvar_type_lazy): Declare. * value.c (create_internalvar): Clear make_value. (create_internalvar_type_lazy): New. (value_of_internalvar): If make_value is set use it. (preserve_values): Skip internal variables that don't have a value. * gdbarch.sh (get_siginfo_type): New. * gdbarch.h, gdbarch.c: Regenerate. * linux-tdep.h, linux-tdep.c: New. * amd64-linux-tdep.c: Include "linux-tdep.h". (amd64_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * i386-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * arm-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * linux-nat.c (linux_xfer_siginfo): New. (linux_nat_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. * remote.c (PACKET_qXfer_siginfo_read) (PACKET_qXfer_siginfo_write): New. (feature remote_protocol_features): Add "qXfer:siginfo:read" and "qXfer:siginfo:write" features. (remote_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. (_initialize_remote): Add "set/show remote read-siginfo-object" and "set/show remote write-siginfo-object" commands. * Makefile.in (ALL_TARGET_OBS): Add linux-tdep.o. (HFILES_NO_SRCDIR): Add linux-tdep.h. (ALLDEPFILES): Add linux-tdep.c. * configure.tgt (arm*-*-linux* | arm*-*-uclinux*) (i[34567]86-*-linux*, x86_64-*-linux*): Add linux-tdep.o to gdb_target_obs. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/gdbserver/ * server.c (handle_query): Report qXfer:siginfo:read and qXfer:siginfo:write as supported and handle them. * target.h (struct target_ops) <qxfer_siginfo>: New field. * linux-low.c (linux_xfer_siginfo): New. (linux_target_ops): Set it. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/doc/ * gdb.texinfo (Signals): Document $_siginfo. (Convenience Variables): Mention $_siginfo. (Remote Configuration): Document qXfer:siginfo:read, qXfer:siginfo:write packets, and the read-siginfo-object, write-siginfo-object commands. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/testsuite/ * gdb.base/siginfo-obj.c, gdb.base/siginfo-obj.exp: New.
2009-02-06 23:59:01 +01:00
return -1;
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
pid = lwpid_of (current_thread);
2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/ * target.h (enum target_object): Add new TARGET_OBJECT_SIGNAL_INFO. * infrun.c (siginfo_value_read, siginfo_value_write): New. (siginfo_value_funcs): New. (siginfo_make_value): New. (_initialize_infrun): Create the $_siginfo convenience variable. * gdbtypes.h (append_composite_type_field_aligned): Declare. * gdbtypes.c (append_composite_type_field): Rename to... (append_composite_type_field_aligned): ... this. Add ALIGNMENT argument. Handle it. (append_composite_type_field): Rewrite on top of append_composite_type_field_aligned. * value.h (internalvar_make_value): New typedef. (struct internalvar) <make_value>: New field. (create_internalvar_type_lazy): Declare. * value.c (create_internalvar): Clear make_value. (create_internalvar_type_lazy): New. (value_of_internalvar): If make_value is set use it. (preserve_values): Skip internal variables that don't have a value. * gdbarch.sh (get_siginfo_type): New. * gdbarch.h, gdbarch.c: Regenerate. * linux-tdep.h, linux-tdep.c: New. * amd64-linux-tdep.c: Include "linux-tdep.h". (amd64_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * i386-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * arm-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * linux-nat.c (linux_xfer_siginfo): New. (linux_nat_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. * remote.c (PACKET_qXfer_siginfo_read) (PACKET_qXfer_siginfo_write): New. (feature remote_protocol_features): Add "qXfer:siginfo:read" and "qXfer:siginfo:write" features. (remote_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. (_initialize_remote): Add "set/show remote read-siginfo-object" and "set/show remote write-siginfo-object" commands. * Makefile.in (ALL_TARGET_OBS): Add linux-tdep.o. (HFILES_NO_SRCDIR): Add linux-tdep.h. (ALLDEPFILES): Add linux-tdep.c. * configure.tgt (arm*-*-linux* | arm*-*-uclinux*) (i[34567]86-*-linux*, x86_64-*-linux*): Add linux-tdep.o to gdb_target_obs. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/gdbserver/ * server.c (handle_query): Report qXfer:siginfo:read and qXfer:siginfo:write as supported and handle them. * target.h (struct target_ops) <qxfer_siginfo>: New field. * linux-low.c (linux_xfer_siginfo): New. (linux_target_ops): Set it. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/doc/ * gdb.texinfo (Signals): Document $_siginfo. (Convenience Variables): Mention $_siginfo. (Remote Configuration): Document qXfer:siginfo:read, qXfer:siginfo:write packets, and the read-siginfo-object, write-siginfo-object commands. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/testsuite/ * gdb.base/siginfo-obj.c, gdb.base/siginfo-obj.exp: New.
2009-02-06 23:59:01 +01:00
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("%s siginfo for lwp %d.\n",
readbuf != NULL ? "Reading" : "Writing",
pid);
2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/ * target.h (enum target_object): Add new TARGET_OBJECT_SIGNAL_INFO. * infrun.c (siginfo_value_read, siginfo_value_write): New. (siginfo_value_funcs): New. (siginfo_make_value): New. (_initialize_infrun): Create the $_siginfo convenience variable. * gdbtypes.h (append_composite_type_field_aligned): Declare. * gdbtypes.c (append_composite_type_field): Rename to... (append_composite_type_field_aligned): ... this. Add ALIGNMENT argument. Handle it. (append_composite_type_field): Rewrite on top of append_composite_type_field_aligned. * value.h (internalvar_make_value): New typedef. (struct internalvar) <make_value>: New field. (create_internalvar_type_lazy): Declare. * value.c (create_internalvar): Clear make_value. (create_internalvar_type_lazy): New. (value_of_internalvar): If make_value is set use it. (preserve_values): Skip internal variables that don't have a value. * gdbarch.sh (get_siginfo_type): New. * gdbarch.h, gdbarch.c: Regenerate. * linux-tdep.h, linux-tdep.c: New. * amd64-linux-tdep.c: Include "linux-tdep.h". (amd64_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * i386-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * arm-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * linux-nat.c (linux_xfer_siginfo): New. (linux_nat_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. * remote.c (PACKET_qXfer_siginfo_read) (PACKET_qXfer_siginfo_write): New. (feature remote_protocol_features): Add "qXfer:siginfo:read" and "qXfer:siginfo:write" features. (remote_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. (_initialize_remote): Add "set/show remote read-siginfo-object" and "set/show remote write-siginfo-object" commands. * Makefile.in (ALL_TARGET_OBS): Add linux-tdep.o. (HFILES_NO_SRCDIR): Add linux-tdep.h. (ALLDEPFILES): Add linux-tdep.c. * configure.tgt (arm*-*-linux* | arm*-*-uclinux*) (i[34567]86-*-linux*, x86_64-*-linux*): Add linux-tdep.o to gdb_target_obs. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/gdbserver/ * server.c (handle_query): Report qXfer:siginfo:read and qXfer:siginfo:write as supported and handle them. * target.h (struct target_ops) <qxfer_siginfo>: New field. * linux-low.c (linux_xfer_siginfo): New. (linux_target_ops): Set it. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/doc/ * gdb.texinfo (Signals): Document $_siginfo. (Convenience Variables): Mention $_siginfo. (Remote Configuration): Document qXfer:siginfo:read, qXfer:siginfo:write packets, and the read-siginfo-object, write-siginfo-object commands. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/testsuite/ * gdb.base/siginfo-obj.c, gdb.base/siginfo-obj.exp: New.
2009-02-06 23:59:01 +01:00
if (offset >= sizeof (siginfo))
2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/ * target.h (enum target_object): Add new TARGET_OBJECT_SIGNAL_INFO. * infrun.c (siginfo_value_read, siginfo_value_write): New. (siginfo_value_funcs): New. (siginfo_make_value): New. (_initialize_infrun): Create the $_siginfo convenience variable. * gdbtypes.h (append_composite_type_field_aligned): Declare. * gdbtypes.c (append_composite_type_field): Rename to... (append_composite_type_field_aligned): ... this. Add ALIGNMENT argument. Handle it. (append_composite_type_field): Rewrite on top of append_composite_type_field_aligned. * value.h (internalvar_make_value): New typedef. (struct internalvar) <make_value>: New field. (create_internalvar_type_lazy): Declare. * value.c (create_internalvar): Clear make_value. (create_internalvar_type_lazy): New. (value_of_internalvar): If make_value is set use it. (preserve_values): Skip internal variables that don't have a value. * gdbarch.sh (get_siginfo_type): New. * gdbarch.h, gdbarch.c: Regenerate. * linux-tdep.h, linux-tdep.c: New. * amd64-linux-tdep.c: Include "linux-tdep.h". (amd64_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * i386-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * arm-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * linux-nat.c (linux_xfer_siginfo): New. (linux_nat_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. * remote.c (PACKET_qXfer_siginfo_read) (PACKET_qXfer_siginfo_write): New. (feature remote_protocol_features): Add "qXfer:siginfo:read" and "qXfer:siginfo:write" features. (remote_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. (_initialize_remote): Add "set/show remote read-siginfo-object" and "set/show remote write-siginfo-object" commands. * Makefile.in (ALL_TARGET_OBS): Add linux-tdep.o. (HFILES_NO_SRCDIR): Add linux-tdep.h. (ALLDEPFILES): Add linux-tdep.c. * configure.tgt (arm*-*-linux* | arm*-*-uclinux*) (i[34567]86-*-linux*, x86_64-*-linux*): Add linux-tdep.o to gdb_target_obs. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/gdbserver/ * server.c (handle_query): Report qXfer:siginfo:read and qXfer:siginfo:write as supported and handle them. * target.h (struct target_ops) <qxfer_siginfo>: New field. * linux-low.c (linux_xfer_siginfo): New. (linux_target_ops): Set it. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/doc/ * gdb.texinfo (Signals): Document $_siginfo. (Convenience Variables): Mention $_siginfo. (Remote Configuration): Document qXfer:siginfo:read, qXfer:siginfo:write packets, and the read-siginfo-object, write-siginfo-object commands. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/testsuite/ * gdb.base/siginfo-obj.c, gdb.base/siginfo-obj.exp: New.
2009-02-06 23:59:01 +01:00
return -1;
if (ptrace (PTRACE_GETSIGINFO, pid, (PTRACE_TYPE_ARG3) 0, &siginfo) != 0)
2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/ * target.h (enum target_object): Add new TARGET_OBJECT_SIGNAL_INFO. * infrun.c (siginfo_value_read, siginfo_value_write): New. (siginfo_value_funcs): New. (siginfo_make_value): New. (_initialize_infrun): Create the $_siginfo convenience variable. * gdbtypes.h (append_composite_type_field_aligned): Declare. * gdbtypes.c (append_composite_type_field): Rename to... (append_composite_type_field_aligned): ... this. Add ALIGNMENT argument. Handle it. (append_composite_type_field): Rewrite on top of append_composite_type_field_aligned. * value.h (internalvar_make_value): New typedef. (struct internalvar) <make_value>: New field. (create_internalvar_type_lazy): Declare. * value.c (create_internalvar): Clear make_value. (create_internalvar_type_lazy): New. (value_of_internalvar): If make_value is set use it. (preserve_values): Skip internal variables that don't have a value. * gdbarch.sh (get_siginfo_type): New. * gdbarch.h, gdbarch.c: Regenerate. * linux-tdep.h, linux-tdep.c: New. * amd64-linux-tdep.c: Include "linux-tdep.h". (amd64_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * i386-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * arm-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * linux-nat.c (linux_xfer_siginfo): New. (linux_nat_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. * remote.c (PACKET_qXfer_siginfo_read) (PACKET_qXfer_siginfo_write): New. (feature remote_protocol_features): Add "qXfer:siginfo:read" and "qXfer:siginfo:write" features. (remote_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. (_initialize_remote): Add "set/show remote read-siginfo-object" and "set/show remote write-siginfo-object" commands. * Makefile.in (ALL_TARGET_OBS): Add linux-tdep.o. (HFILES_NO_SRCDIR): Add linux-tdep.h. (ALLDEPFILES): Add linux-tdep.c. * configure.tgt (arm*-*-linux* | arm*-*-uclinux*) (i[34567]86-*-linux*, x86_64-*-linux*): Add linux-tdep.o to gdb_target_obs. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/gdbserver/ * server.c (handle_query): Report qXfer:siginfo:read and qXfer:siginfo:write as supported and handle them. * target.h (struct target_ops) <qxfer_siginfo>: New field. * linux-low.c (linux_xfer_siginfo): New. (linux_target_ops): Set it. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/doc/ * gdb.texinfo (Signals): Document $_siginfo. (Convenience Variables): Mention $_siginfo. (Remote Configuration): Document qXfer:siginfo:read, qXfer:siginfo:write packets, and the read-siginfo-object, write-siginfo-object commands. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/testsuite/ * gdb.base/siginfo-obj.c, gdb.base/siginfo-obj.exp: New.
2009-02-06 23:59:01 +01:00
return -1;
/* When GDBSERVER is built as a 64-bit application, ptrace writes into
SIGINFO an object with 64-bit layout. Since debugging a 32-bit
inferior with a 64-bit GDBSERVER should look the same as debugging it
with a 32-bit GDBSERVER, we need to convert it. */
siginfo_fixup (&siginfo, inf_siginfo, 0);
2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/ * target.h (enum target_object): Add new TARGET_OBJECT_SIGNAL_INFO. * infrun.c (siginfo_value_read, siginfo_value_write): New. (siginfo_value_funcs): New. (siginfo_make_value): New. (_initialize_infrun): Create the $_siginfo convenience variable. * gdbtypes.h (append_composite_type_field_aligned): Declare. * gdbtypes.c (append_composite_type_field): Rename to... (append_composite_type_field_aligned): ... this. Add ALIGNMENT argument. Handle it. (append_composite_type_field): Rewrite on top of append_composite_type_field_aligned. * value.h (internalvar_make_value): New typedef. (struct internalvar) <make_value>: New field. (create_internalvar_type_lazy): Declare. * value.c (create_internalvar): Clear make_value. (create_internalvar_type_lazy): New. (value_of_internalvar): If make_value is set use it. (preserve_values): Skip internal variables that don't have a value. * gdbarch.sh (get_siginfo_type): New. * gdbarch.h, gdbarch.c: Regenerate. * linux-tdep.h, linux-tdep.c: New. * amd64-linux-tdep.c: Include "linux-tdep.h". (amd64_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * i386-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * arm-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * linux-nat.c (linux_xfer_siginfo): New. (linux_nat_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. * remote.c (PACKET_qXfer_siginfo_read) (PACKET_qXfer_siginfo_write): New. (feature remote_protocol_features): Add "qXfer:siginfo:read" and "qXfer:siginfo:write" features. (remote_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. (_initialize_remote): Add "set/show remote read-siginfo-object" and "set/show remote write-siginfo-object" commands. * Makefile.in (ALL_TARGET_OBS): Add linux-tdep.o. (HFILES_NO_SRCDIR): Add linux-tdep.h. (ALLDEPFILES): Add linux-tdep.c. * configure.tgt (arm*-*-linux* | arm*-*-uclinux*) (i[34567]86-*-linux*, x86_64-*-linux*): Add linux-tdep.o to gdb_target_obs. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/gdbserver/ * server.c (handle_query): Report qXfer:siginfo:read and qXfer:siginfo:write as supported and handle them. * target.h (struct target_ops) <qxfer_siginfo>: New field. * linux-low.c (linux_xfer_siginfo): New. (linux_target_ops): Set it. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/doc/ * gdb.texinfo (Signals): Document $_siginfo. (Convenience Variables): Mention $_siginfo. (Remote Configuration): Document qXfer:siginfo:read, qXfer:siginfo:write packets, and the read-siginfo-object, write-siginfo-object commands. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/testsuite/ * gdb.base/siginfo-obj.c, gdb.base/siginfo-obj.exp: New.
2009-02-06 23:59:01 +01:00
if (offset + len > sizeof (siginfo))
len = sizeof (siginfo) - offset;
if (readbuf != NULL)
memcpy (readbuf, inf_siginfo + offset, len);
2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/ * target.h (enum target_object): Add new TARGET_OBJECT_SIGNAL_INFO. * infrun.c (siginfo_value_read, siginfo_value_write): New. (siginfo_value_funcs): New. (siginfo_make_value): New. (_initialize_infrun): Create the $_siginfo convenience variable. * gdbtypes.h (append_composite_type_field_aligned): Declare. * gdbtypes.c (append_composite_type_field): Rename to... (append_composite_type_field_aligned): ... this. Add ALIGNMENT argument. Handle it. (append_composite_type_field): Rewrite on top of append_composite_type_field_aligned. * value.h (internalvar_make_value): New typedef. (struct internalvar) <make_value>: New field. (create_internalvar_type_lazy): Declare. * value.c (create_internalvar): Clear make_value. (create_internalvar_type_lazy): New. (value_of_internalvar): If make_value is set use it. (preserve_values): Skip internal variables that don't have a value. * gdbarch.sh (get_siginfo_type): New. * gdbarch.h, gdbarch.c: Regenerate. * linux-tdep.h, linux-tdep.c: New. * amd64-linux-tdep.c: Include "linux-tdep.h". (amd64_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * i386-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * arm-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * linux-nat.c (linux_xfer_siginfo): New. (linux_nat_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. * remote.c (PACKET_qXfer_siginfo_read) (PACKET_qXfer_siginfo_write): New. (feature remote_protocol_features): Add "qXfer:siginfo:read" and "qXfer:siginfo:write" features. (remote_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. (_initialize_remote): Add "set/show remote read-siginfo-object" and "set/show remote write-siginfo-object" commands. * Makefile.in (ALL_TARGET_OBS): Add linux-tdep.o. (HFILES_NO_SRCDIR): Add linux-tdep.h. (ALLDEPFILES): Add linux-tdep.c. * configure.tgt (arm*-*-linux* | arm*-*-uclinux*) (i[34567]86-*-linux*, x86_64-*-linux*): Add linux-tdep.o to gdb_target_obs. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/gdbserver/ * server.c (handle_query): Report qXfer:siginfo:read and qXfer:siginfo:write as supported and handle them. * target.h (struct target_ops) <qxfer_siginfo>: New field. * linux-low.c (linux_xfer_siginfo): New. (linux_target_ops): Set it. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/doc/ * gdb.texinfo (Signals): Document $_siginfo. (Convenience Variables): Mention $_siginfo. (Remote Configuration): Document qXfer:siginfo:read, qXfer:siginfo:write packets, and the read-siginfo-object, write-siginfo-object commands. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/testsuite/ * gdb.base/siginfo-obj.c, gdb.base/siginfo-obj.exp: New.
2009-02-06 23:59:01 +01:00
else
{
memcpy (inf_siginfo + offset, writebuf, len);
/* Convert back to ptrace layout before flushing it out. */
siginfo_fixup (&siginfo, inf_siginfo, 1);
if (ptrace (PTRACE_SETSIGINFO, pid, (PTRACE_TYPE_ARG3) 0, &siginfo) != 0)
2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/ * target.h (enum target_object): Add new TARGET_OBJECT_SIGNAL_INFO. * infrun.c (siginfo_value_read, siginfo_value_write): New. (siginfo_value_funcs): New. (siginfo_make_value): New. (_initialize_infrun): Create the $_siginfo convenience variable. * gdbtypes.h (append_composite_type_field_aligned): Declare. * gdbtypes.c (append_composite_type_field): Rename to... (append_composite_type_field_aligned): ... this. Add ALIGNMENT argument. Handle it. (append_composite_type_field): Rewrite on top of append_composite_type_field_aligned. * value.h (internalvar_make_value): New typedef. (struct internalvar) <make_value>: New field. (create_internalvar_type_lazy): Declare. * value.c (create_internalvar): Clear make_value. (create_internalvar_type_lazy): New. (value_of_internalvar): If make_value is set use it. (preserve_values): Skip internal variables that don't have a value. * gdbarch.sh (get_siginfo_type): New. * gdbarch.h, gdbarch.c: Regenerate. * linux-tdep.h, linux-tdep.c: New. * amd64-linux-tdep.c: Include "linux-tdep.h". (amd64_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * i386-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * arm-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * linux-nat.c (linux_xfer_siginfo): New. (linux_nat_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. * remote.c (PACKET_qXfer_siginfo_read) (PACKET_qXfer_siginfo_write): New. (feature remote_protocol_features): Add "qXfer:siginfo:read" and "qXfer:siginfo:write" features. (remote_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. (_initialize_remote): Add "set/show remote read-siginfo-object" and "set/show remote write-siginfo-object" commands. * Makefile.in (ALL_TARGET_OBS): Add linux-tdep.o. (HFILES_NO_SRCDIR): Add linux-tdep.h. (ALLDEPFILES): Add linux-tdep.c. * configure.tgt (arm*-*-linux* | arm*-*-uclinux*) (i[34567]86-*-linux*, x86_64-*-linux*): Add linux-tdep.o to gdb_target_obs. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/gdbserver/ * server.c (handle_query): Report qXfer:siginfo:read and qXfer:siginfo:write as supported and handle them. * target.h (struct target_ops) <qxfer_siginfo>: New field. * linux-low.c (linux_xfer_siginfo): New. (linux_target_ops): Set it. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/doc/ * gdb.texinfo (Signals): Document $_siginfo. (Convenience Variables): Mention $_siginfo. (Remote Configuration): Document qXfer:siginfo:read, qXfer:siginfo:write packets, and the read-siginfo-object, write-siginfo-object commands. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/testsuite/ * gdb.base/siginfo-obj.c, gdb.base/siginfo-obj.exp: New.
2009-02-06 23:59:01 +01:00
return -1;
}
return len;
}
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
/* SIGCHLD handler that serves two purposes: In non-stop/async mode,
so we notice when children change state; as the handler for the
sigsuspend in my_waitpid. */
static void
sigchld_handler (int signo)
{
int old_errno = errno;
if (debug_threads)
{
do
{
/* Use the async signal safe debug function. */
if (debug_write ("sigchld_handler\n",
sizeof ("sigchld_handler\n") - 1) < 0)
break; /* just ignore */
} while (0);
}
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
if (target_is_async_p ())
async_file_mark (); /* trigger a linux_wait */
errno = old_errno;
}
bool
linux_process_target::supports_non_stop ()
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
{
return true;
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
}
bool
linux_process_target::async (bool enable)
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
{
bool previous = target_is_async_p ();
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("linux_async (%d), previous=%d\n",
enable, previous);
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
if (previous != enable)
{
sigset_t mask;
sigemptyset (&mask);
sigaddset (&mask, SIGCHLD);
Add RAII class for blocking gdb signals This adds configury support and an RAII class that can be used to temporarily block signals that are used by gdb. (This class is not used in this patch, but it split out for easier review.) The idea of this patch is that these signals should only be delivered to the main thread. So, when creating a background thread, they are temporarily blocked; the blocked state is inherited by the new thread. The sigprocmask man page says: The use of sigprocmask() is unspecified in a multithreaded process; see pthread_sigmask(3). This patch changes gdb to use pthread_sigmask when appropriate, by introducing a convenience define. I've updated gdbserver as well, because I had to touch gdbsupport, and because the threading patches will make it link against the thread library. I chose not to touch the NTO code, because I don't know anything about that platform and because I cannot test it. Finally, this modifies an existing spot in the Guile layer to use the new facility. gdb/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * gdbsupport/signals-state-save-restore.c (original_signal_mask): Remove comment. (save_original_signals_state, restore_original_signals_state): Use gdb_sigmask. * linux-nat.c (block_child_signals, restore_child_signals_mask) (_initialize_linux_nat): Use gdb_sigmask. * guile/guile.c (_initialize_guile): Use block_signals. * Makefile.in (HFILES_NO_SRCDIR): Add gdb-sigmask.h. * gdbsupport/gdb-sigmask.h: New file. * event-top.c (async_sigtstp_handler): Use gdb_sigmask. * cp-support.c (gdb_demangle): Use gdb_sigmask. * gdbsupport/common.m4 (GDB_AC_COMMON): Check for pthread_sigmask. * configure, config.in: Rebuild. * gdbsupport/block-signals.h: New file. gdb/gdbserver/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * remote-utils.c (block_unblock_async_io): Use gdb_sigmask. * linux-low.c (linux_wait_for_event_filtered, linux_async): Use gdb_sigmask. * configure, config.in: Rebuild. Change-Id: If3f37dc57dd859c226e9e4d79458a0514746e8c6
2019-09-29 16:50:15 +02:00
gdb_sigmask (SIG_BLOCK, &mask, NULL);
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
if (enable)
{
if (pipe (linux_event_pipe) == -1)
{
linux_event_pipe[0] = -1;
linux_event_pipe[1] = -1;
Add RAII class for blocking gdb signals This adds configury support and an RAII class that can be used to temporarily block signals that are used by gdb. (This class is not used in this patch, but it split out for easier review.) The idea of this patch is that these signals should only be delivered to the main thread. So, when creating a background thread, they are temporarily blocked; the blocked state is inherited by the new thread. The sigprocmask man page says: The use of sigprocmask() is unspecified in a multithreaded process; see pthread_sigmask(3). This patch changes gdb to use pthread_sigmask when appropriate, by introducing a convenience define. I've updated gdbserver as well, because I had to touch gdbsupport, and because the threading patches will make it link against the thread library. I chose not to touch the NTO code, because I don't know anything about that platform and because I cannot test it. Finally, this modifies an existing spot in the Guile layer to use the new facility. gdb/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * gdbsupport/signals-state-save-restore.c (original_signal_mask): Remove comment. (save_original_signals_state, restore_original_signals_state): Use gdb_sigmask. * linux-nat.c (block_child_signals, restore_child_signals_mask) (_initialize_linux_nat): Use gdb_sigmask. * guile/guile.c (_initialize_guile): Use block_signals. * Makefile.in (HFILES_NO_SRCDIR): Add gdb-sigmask.h. * gdbsupport/gdb-sigmask.h: New file. * event-top.c (async_sigtstp_handler): Use gdb_sigmask. * cp-support.c (gdb_demangle): Use gdb_sigmask. * gdbsupport/common.m4 (GDB_AC_COMMON): Check for pthread_sigmask. * configure, config.in: Rebuild. * gdbsupport/block-signals.h: New file. gdb/gdbserver/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * remote-utils.c (block_unblock_async_io): Use gdb_sigmask. * linux-low.c (linux_wait_for_event_filtered, linux_async): Use gdb_sigmask. * configure, config.in: Rebuild. Change-Id: If3f37dc57dd859c226e9e4d79458a0514746e8c6
2019-09-29 16:50:15 +02:00
gdb_sigmask (SIG_UNBLOCK, &mask, NULL);
warning ("creating event pipe failed.");
return previous;
}
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
fcntl (linux_event_pipe[0], F_SETFL, O_NONBLOCK);
fcntl (linux_event_pipe[1], F_SETFL, O_NONBLOCK);
/* Register the event loop handler. */
add_file_handler (linux_event_pipe[0],
handle_target_event, NULL);
/* Always trigger a linux_wait. */
async_file_mark ();
}
else
{
delete_file_handler (linux_event_pipe[0]);
close (linux_event_pipe[0]);
close (linux_event_pipe[1]);
linux_event_pipe[0] = -1;
linux_event_pipe[1] = -1;
}
Add RAII class for blocking gdb signals This adds configury support and an RAII class that can be used to temporarily block signals that are used by gdb. (This class is not used in this patch, but it split out for easier review.) The idea of this patch is that these signals should only be delivered to the main thread. So, when creating a background thread, they are temporarily blocked; the blocked state is inherited by the new thread. The sigprocmask man page says: The use of sigprocmask() is unspecified in a multithreaded process; see pthread_sigmask(3). This patch changes gdb to use pthread_sigmask when appropriate, by introducing a convenience define. I've updated gdbserver as well, because I had to touch gdbsupport, and because the threading patches will make it link against the thread library. I chose not to touch the NTO code, because I don't know anything about that platform and because I cannot test it. Finally, this modifies an existing spot in the Guile layer to use the new facility. gdb/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * gdbsupport/signals-state-save-restore.c (original_signal_mask): Remove comment. (save_original_signals_state, restore_original_signals_state): Use gdb_sigmask. * linux-nat.c (block_child_signals, restore_child_signals_mask) (_initialize_linux_nat): Use gdb_sigmask. * guile/guile.c (_initialize_guile): Use block_signals. * Makefile.in (HFILES_NO_SRCDIR): Add gdb-sigmask.h. * gdbsupport/gdb-sigmask.h: New file. * event-top.c (async_sigtstp_handler): Use gdb_sigmask. * cp-support.c (gdb_demangle): Use gdb_sigmask. * gdbsupport/common.m4 (GDB_AC_COMMON): Check for pthread_sigmask. * configure, config.in: Rebuild. * gdbsupport/block-signals.h: New file. gdb/gdbserver/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * remote-utils.c (block_unblock_async_io): Use gdb_sigmask. * linux-low.c (linux_wait_for_event_filtered, linux_async): Use gdb_sigmask. * configure, config.in: Rebuild. Change-Id: If3f37dc57dd859c226e9e4d79458a0514746e8c6
2019-09-29 16:50:15 +02:00
gdb_sigmask (SIG_UNBLOCK, &mask, NULL);
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
}
return previous;
}
int
linux_process_target::start_non_stop (bool nonstop)
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
{
/* Register or unregister from event-loop accordingly. */
target_async (nonstop);
if (target_is_async_p () != (nonstop != false))
return -1;
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
return 0;
}
bool
linux_process_target::supports_multi_process ()
{
return true;
}
Identify remote fork event support This patch implements a mechanism for GDB to determine whether fork events are supported in gdbserver. This is a preparatory patch for remote fork and exec event support. Two new RSP packets are defined to represent fork and vfork event support. These packets are used just like PACKET_multiprocess_feature to denote whether the corresponding event is supported. GDB sends fork-events+ and vfork-events+ to gdbserver to inquire about fork event support. If the response enables these packets, then GDB knows that gdbserver supports the corresponding events and will enable them. Target functions used to query for support are included along with each new packet. In order for gdbserver to know whether the events are supported at the point where the qSupported packet arrives, the code in nat/linux-ptrace.c had to be reorganized. Previously it would test for fork/exec event support, then enable the events using the pid of the inferior. When the qSupported packet arrives there may not be an inferior. So the mechanism was split into two parts: a function that checks whether the events are supported, called when gdbserver starts up, and another that enables the events when the inferior stops for the first time. Another gdbserver change was to add some global variables similar to multi_process, one per new packet. These are used to control whether the corresponding fork events are enabled. If GDB does not inquire about the event support in the qSupported packet, then gdbserver will not set these "report the event" flags. If the flags are not set, the events are ignored like they were in the past. Thus, gdbserver will never send fork event notification to an older GDB that doesn't recognize fork events. Tested on Ubuntu x64, native/remote/extended-remote, and as part of subsequent patches in the series. gdb/gdbserver/ChangeLog: * linux-low.c (linux_supports_fork_events): New function. (linux_supports_vfork_events): New function. (linux_target_ops): Initialize new structure members. (initialize_low): Call linux_check_ptrace_features. * lynx-low.c (lynx_target_ops): Initialize new structure members. * server.c (report_fork_events, report_vfork_events): New global flags. (handle_query): Add new features to qSupported packet and response. (captured_main): Initialize new global variables. * target.h (struct target_ops) <supports_fork_events>: New member. <supports_vfork_events>: New member. (target_supports_fork_events): New macro. (target_supports_vfork_events): New macro. * win32-low.c (win32_target_ops): Initialize new structure members. gdb/ChangeLog: * nat/linux-ptrace.c (linux_check_ptrace_features): Change from static to extern. * nat/linux-ptrace.h (linux_check_ptrace_features): Declare. * remote.c (anonymous enum): <PACKET_fork_event_feature, * PACKET_vfork_event_feature>: New enumeration constants. (remote_protocol_features): Add table entries for new packets. (remote_query_supported): Add new feature queries to qSupported packet. (_initialize_remote): Exempt new packets from the requirement to have 'set remote' commands.
2015-05-12 18:52:41 +02:00
/* Check if fork events are supported. */
bool
linux_process_target::supports_fork_events ()
Identify remote fork event support This patch implements a mechanism for GDB to determine whether fork events are supported in gdbserver. This is a preparatory patch for remote fork and exec event support. Two new RSP packets are defined to represent fork and vfork event support. These packets are used just like PACKET_multiprocess_feature to denote whether the corresponding event is supported. GDB sends fork-events+ and vfork-events+ to gdbserver to inquire about fork event support. If the response enables these packets, then GDB knows that gdbserver supports the corresponding events and will enable them. Target functions used to query for support are included along with each new packet. In order for gdbserver to know whether the events are supported at the point where the qSupported packet arrives, the code in nat/linux-ptrace.c had to be reorganized. Previously it would test for fork/exec event support, then enable the events using the pid of the inferior. When the qSupported packet arrives there may not be an inferior. So the mechanism was split into two parts: a function that checks whether the events are supported, called when gdbserver starts up, and another that enables the events when the inferior stops for the first time. Another gdbserver change was to add some global variables similar to multi_process, one per new packet. These are used to control whether the corresponding fork events are enabled. If GDB does not inquire about the event support in the qSupported packet, then gdbserver will not set these "report the event" flags. If the flags are not set, the events are ignored like they were in the past. Thus, gdbserver will never send fork event notification to an older GDB that doesn't recognize fork events. Tested on Ubuntu x64, native/remote/extended-remote, and as part of subsequent patches in the series. gdb/gdbserver/ChangeLog: * linux-low.c (linux_supports_fork_events): New function. (linux_supports_vfork_events): New function. (linux_target_ops): Initialize new structure members. (initialize_low): Call linux_check_ptrace_features. * lynx-low.c (lynx_target_ops): Initialize new structure members. * server.c (report_fork_events, report_vfork_events): New global flags. (handle_query): Add new features to qSupported packet and response. (captured_main): Initialize new global variables. * target.h (struct target_ops) <supports_fork_events>: New member. <supports_vfork_events>: New member. (target_supports_fork_events): New macro. (target_supports_vfork_events): New macro. * win32-low.c (win32_target_ops): Initialize new structure members. gdb/ChangeLog: * nat/linux-ptrace.c (linux_check_ptrace_features): Change from static to extern. * nat/linux-ptrace.h (linux_check_ptrace_features): Declare. * remote.c (anonymous enum): <PACKET_fork_event_feature, * PACKET_vfork_event_feature>: New enumeration constants. (remote_protocol_features): Add table entries for new packets. (remote_query_supported): Add new feature queries to qSupported packet. (_initialize_remote): Exempt new packets from the requirement to have 'set remote' commands.
2015-05-12 18:52:41 +02:00
{
return linux_supports_tracefork ();
}
/* Check if vfork events are supported. */
bool
linux_process_target::supports_vfork_events ()
Identify remote fork event support This patch implements a mechanism for GDB to determine whether fork events are supported in gdbserver. This is a preparatory patch for remote fork and exec event support. Two new RSP packets are defined to represent fork and vfork event support. These packets are used just like PACKET_multiprocess_feature to denote whether the corresponding event is supported. GDB sends fork-events+ and vfork-events+ to gdbserver to inquire about fork event support. If the response enables these packets, then GDB knows that gdbserver supports the corresponding events and will enable them. Target functions used to query for support are included along with each new packet. In order for gdbserver to know whether the events are supported at the point where the qSupported packet arrives, the code in nat/linux-ptrace.c had to be reorganized. Previously it would test for fork/exec event support, then enable the events using the pid of the inferior. When the qSupported packet arrives there may not be an inferior. So the mechanism was split into two parts: a function that checks whether the events are supported, called when gdbserver starts up, and another that enables the events when the inferior stops for the first time. Another gdbserver change was to add some global variables similar to multi_process, one per new packet. These are used to control whether the corresponding fork events are enabled. If GDB does not inquire about the event support in the qSupported packet, then gdbserver will not set these "report the event" flags. If the flags are not set, the events are ignored like they were in the past. Thus, gdbserver will never send fork event notification to an older GDB that doesn't recognize fork events. Tested on Ubuntu x64, native/remote/extended-remote, and as part of subsequent patches in the series. gdb/gdbserver/ChangeLog: * linux-low.c (linux_supports_fork_events): New function. (linux_supports_vfork_events): New function. (linux_target_ops): Initialize new structure members. (initialize_low): Call linux_check_ptrace_features. * lynx-low.c (lynx_target_ops): Initialize new structure members. * server.c (report_fork_events, report_vfork_events): New global flags. (handle_query): Add new features to qSupported packet and response. (captured_main): Initialize new global variables. * target.h (struct target_ops) <supports_fork_events>: New member. <supports_vfork_events>: New member. (target_supports_fork_events): New macro. (target_supports_vfork_events): New macro. * win32-low.c (win32_target_ops): Initialize new structure members. gdb/ChangeLog: * nat/linux-ptrace.c (linux_check_ptrace_features): Change from static to extern. * nat/linux-ptrace.h (linux_check_ptrace_features): Declare. * remote.c (anonymous enum): <PACKET_fork_event_feature, * PACKET_vfork_event_feature>: New enumeration constants. (remote_protocol_features): Add table entries for new packets. (remote_query_supported): Add new feature queries to qSupported packet. (_initialize_remote): Exempt new packets from the requirement to have 'set remote' commands.
2015-05-12 18:52:41 +02:00
{
return linux_supports_tracefork ();
}
Extended-remote follow-exec This patch implements support for exec events on extended-remote Linux targets. Follow-exec-mode and rerun behave as expected. Catchpoints and test updates are implemented in subsequent patches. This patch was derived from a patch posted last October: https://sourceware.org/ml/gdb-patches/2014-10/msg00877.html. It was originally based on some work done by Luis Machado in 2013. IMPLEMENTATION ---------------- Exec events are enabled via ptrace options. When an exec event is detected by gdbserver, the existing process data, along with all its associated lwp and thread data, is deleted and replaced by data for a new single-threaded process. The new process data is initialized with the appropriate parts of the state of the execing process. This approach takes care of several potential pitfalls, including: * deleting the data for an execing non-leader thread before any wait/sigsuspend occurs * correctly initializing the architecture of the execed process We then report the exec event using a new RSP stop reason, "exec". When GDB receives an "exec" event, it saves the status in the event structure's target_waitstatus field, like what is done for remote fork events. Because the original and execed programs may have different architectures, we skip parsing the section of the stop reply packet that contains register data. The register data will be retrieved later after the inferior's architecture has been set up by infrun.c:follow_exec. At that point the exec event is handled by the existing event handling in GDB. However, a few changes were necessary so that infrun.c:follow_exec could accommodate the remote target. * Where follow-exec-mode "new" is handled, we now call add_inferior_with_spaces instead of add_inferior with separate calls to set up the program and address spaces. The motivation for this is that add_inferior_with_spaces also sets up the initial architecture for the inferior, which is needed later by target_find_description when it calls target_gdbarch. * We call a new target function, target_follow_exec. This function allows us to store the execd_pathname in the inferior, instead of using the static string remote_exec_file from remote.c. The static string didn't work for follow-exec-mode "new", since once you switched to the execed program, the original remote exec-file was lost. The execd_pathname is now stored in the inferior's program space as a REGISTRY field. All of the requisite mechanisms for this are defined in remote.c. gdb/gdbserver/ChangeLog: * linux-low.c (linux_mourn): Static declaration. (linux_arch_setup): Move in front of handle_extended_wait. (linux_arch_setup_thread): New function. (handle_extended_wait): Handle exec events. Call linux_arch_setup_thread. Make event_lwp argument a pointer-to-a-pointer. (check_zombie_leaders): Do not check stopped threads. (linux_low_ptrace_options): Add PTRACE_O_TRACEEXEC. (linux_low_filter_event): Add lwp and thread for exec'ing non-leader thread if leader thread has been deleted. Refactor code into linux_arch_setup_thread and call it. Pass child lwp pointer by reference to handle_extended_wait. (linux_wait_for_event_filtered): Update comment. (linux_wait_1): Prevent clobbering exec event status. (linux_supports_exec_events): New function. (linux_target_ops) <supports_exec_events>: Initialize new member. * lynx-low.c (lynx_target_ops) <supports_exec_events>: Initialize new member. * remote-utils.c (prepare_resume_reply): New stop reason 'exec'. * server.c (report_exec_events): New global variable. (handle_query): Handle qSupported query for exec-events feature. (captured_main): Initialize report_exec_events. * server.h (report_exec_events): Declare new global variable. * target.h (struct target_ops) <supports_exec_events>: New member. (target_supports_exec_events): New macro. * win32-low.c (win32_target_ops) <supports_exec_events>: Initialize new member. gdb/ChangeLog: * infrun.c (follow_exec): Use process-style ptid for exec message. Call add_inferior_with_spaces and target_follow_exec. * nat/linux-ptrace.c (linux_supports_traceexec): New function. * nat/linux-ptrace.h (linux_supports_traceexec): Declare. * remote.c (remote_pspace_data): New static variable. (remote_pspace_data_cleanup): New function. (get_remote_exec_file): New function. (set_remote_exec_file_1): New function. (set_remote_exec_file): New function. (show_remote_exec_file): New function. (remote_exec_file): Delete static variable. (anonymous enum) <PACKET_exec_event_feature> New enumeration constant. (remote_protocol_features): Add entry for exec-events feature. (remote_query_supported): Add client side of qSupported query for exec-events feature. (remote_follow_exec): New function. (remote_parse_stop_reply): Handle 'exec' stop reason. (extended_remote_run, extended_remote_create_inferior): Call get_remote_exec_file and set_remote_exec_file_1. (init_extended_remote_ops) <to_follow_exec>: Initialize new member. (_initialize_remote): Call register_program_space_data_with_cleanup. Call add_packet_config_cmd for remote exec-events feature. Modify call to add_setshow_string_noescape_cmd for exec-file to use new functions set_remote_exec_file and show_remote_exec_file. * target-debug.h, target-delegates.c: Regenerated. * target.c (target_follow_exec): New function. * target.h (struct target_ops) <to_follow_exec>: New member. (target_follow_exec): Declare new function.
2015-09-11 20:06:02 +02:00
/* Check if exec events are supported. */
bool
linux_process_target::supports_exec_events ()
Extended-remote follow-exec This patch implements support for exec events on extended-remote Linux targets. Follow-exec-mode and rerun behave as expected. Catchpoints and test updates are implemented in subsequent patches. This patch was derived from a patch posted last October: https://sourceware.org/ml/gdb-patches/2014-10/msg00877.html. It was originally based on some work done by Luis Machado in 2013. IMPLEMENTATION ---------------- Exec events are enabled via ptrace options. When an exec event is detected by gdbserver, the existing process data, along with all its associated lwp and thread data, is deleted and replaced by data for a new single-threaded process. The new process data is initialized with the appropriate parts of the state of the execing process. This approach takes care of several potential pitfalls, including: * deleting the data for an execing non-leader thread before any wait/sigsuspend occurs * correctly initializing the architecture of the execed process We then report the exec event using a new RSP stop reason, "exec". When GDB receives an "exec" event, it saves the status in the event structure's target_waitstatus field, like what is done for remote fork events. Because the original and execed programs may have different architectures, we skip parsing the section of the stop reply packet that contains register data. The register data will be retrieved later after the inferior's architecture has been set up by infrun.c:follow_exec. At that point the exec event is handled by the existing event handling in GDB. However, a few changes were necessary so that infrun.c:follow_exec could accommodate the remote target. * Where follow-exec-mode "new" is handled, we now call add_inferior_with_spaces instead of add_inferior with separate calls to set up the program and address spaces. The motivation for this is that add_inferior_with_spaces also sets up the initial architecture for the inferior, which is needed later by target_find_description when it calls target_gdbarch. * We call a new target function, target_follow_exec. This function allows us to store the execd_pathname in the inferior, instead of using the static string remote_exec_file from remote.c. The static string didn't work for follow-exec-mode "new", since once you switched to the execed program, the original remote exec-file was lost. The execd_pathname is now stored in the inferior's program space as a REGISTRY field. All of the requisite mechanisms for this are defined in remote.c. gdb/gdbserver/ChangeLog: * linux-low.c (linux_mourn): Static declaration. (linux_arch_setup): Move in front of handle_extended_wait. (linux_arch_setup_thread): New function. (handle_extended_wait): Handle exec events. Call linux_arch_setup_thread. Make event_lwp argument a pointer-to-a-pointer. (check_zombie_leaders): Do not check stopped threads. (linux_low_ptrace_options): Add PTRACE_O_TRACEEXEC. (linux_low_filter_event): Add lwp and thread for exec'ing non-leader thread if leader thread has been deleted. Refactor code into linux_arch_setup_thread and call it. Pass child lwp pointer by reference to handle_extended_wait. (linux_wait_for_event_filtered): Update comment. (linux_wait_1): Prevent clobbering exec event status. (linux_supports_exec_events): New function. (linux_target_ops) <supports_exec_events>: Initialize new member. * lynx-low.c (lynx_target_ops) <supports_exec_events>: Initialize new member. * remote-utils.c (prepare_resume_reply): New stop reason 'exec'. * server.c (report_exec_events): New global variable. (handle_query): Handle qSupported query for exec-events feature. (captured_main): Initialize report_exec_events. * server.h (report_exec_events): Declare new global variable. * target.h (struct target_ops) <supports_exec_events>: New member. (target_supports_exec_events): New macro. * win32-low.c (win32_target_ops) <supports_exec_events>: Initialize new member. gdb/ChangeLog: * infrun.c (follow_exec): Use process-style ptid for exec message. Call add_inferior_with_spaces and target_follow_exec. * nat/linux-ptrace.c (linux_supports_traceexec): New function. * nat/linux-ptrace.h (linux_supports_traceexec): Declare. * remote.c (remote_pspace_data): New static variable. (remote_pspace_data_cleanup): New function. (get_remote_exec_file): New function. (set_remote_exec_file_1): New function. (set_remote_exec_file): New function. (show_remote_exec_file): New function. (remote_exec_file): Delete static variable. (anonymous enum) <PACKET_exec_event_feature> New enumeration constant. (remote_protocol_features): Add entry for exec-events feature. (remote_query_supported): Add client side of qSupported query for exec-events feature. (remote_follow_exec): New function. (remote_parse_stop_reply): Handle 'exec' stop reason. (extended_remote_run, extended_remote_create_inferior): Call get_remote_exec_file and set_remote_exec_file_1. (init_extended_remote_ops) <to_follow_exec>: Initialize new member. (_initialize_remote): Call register_program_space_data_with_cleanup. Call add_packet_config_cmd for remote exec-events feature. Modify call to add_setshow_string_noescape_cmd for exec-file to use new functions set_remote_exec_file and show_remote_exec_file. * target-debug.h, target-delegates.c: Regenerated. * target.c (target_follow_exec): New function. * target.h (struct target_ops) <to_follow_exec>: New member. (target_follow_exec): Declare new function.
2015-09-11 20:06:02 +02:00
{
return linux_supports_traceexec ();
}
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
/* Target hook for 'handle_new_gdb_connection'. Causes a reset of the
ptrace flags for all inferiors. This is in case the new GDB connection
doesn't support the same set of events that the previous one did. */
void
linux_process_target::handle_new_gdb_connection ()
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
{
/* Request that all the lwps reset their ptrace options. */
for_each_thread ([] (thread_info *thread)
{
struct lwp_info *lwp = get_thread_lwp (thread);
if (!lwp->stopped)
{
/* Stop the lwp so we can modify its ptrace options. */
lwp->must_set_ptrace_flags = 1;
linux_stop_lwp (lwp);
}
else
{
/* Already stopped; go ahead and set the ptrace options. */
struct process_info *proc = find_process_pid (pid_of (thread));
int options = linux_low_ptrace_options (proc->attached);
linux_enable_event_reporting (lwpid_of (thread), options);
lwp->must_set_ptrace_flags = 0;
}
});
Extended-remote Linux follow fork This patch implements basic support for follow-fork and detach-on-fork on extended-remote Linux targets. Only 'fork' is supported in this patch; 'vfork' support is added n a subsequent patch. This patch depends on the previous patches in the patch series. Sufficient extended-remote functionality has been implemented here to pass gdb.base/multi-forks.exp, as well as gdb.base/foll-fork.exp with the catchpoint tests commented out. Some other fork tests fail with this patch because it doesn't provide the architecture support needed for watchpoint inheritance or fork catchpoints. The implementation follows the same general structure as for the native implementation as much as possible. This implementation includes: * enabling fork events in linux-low.c in initialize_low and linux_enable_extended_features * handling fork events in gdbserver/linux-low.c:handle_extended_wait - when a fork event occurs in gdbserver, we must do the full creation of the new process, thread, lwp, and breakpoint lists. This is required whether or not the new child is destined to be detached-on-fork, because GDB will make target calls that require all the structures. In particular we need the breakpoint lists in order to remove the breakpoints from a detaching child. If we are not detaching the child we will need all these structures anyway. - as part of this event handling we store the target_waitstatus in a new member of the parent lwp_info structure, 'waitstatus'. This is used to store extended event information for reporting to GDB. - handle_extended_wait is given a return value, denoting whether the handled event should be reported to GDB. Previously it had only handled clone events, which were never reported. * using a new predicate in gdbserver to control handling of the fork event (and eventually all extended events) in linux_wait_1. The predicate, extended_event_reported, checks a target_waitstatus.kind for an extended ptrace event. * implementing a new RSP 'T' Stop Reply Packet stop reason: "fork", in gdbserver/remote-utils.c and remote.c. * implementing new target and RSP support for target_follow_fork with target extended-remote. (The RSP components were actually defined in patch 1, but they see their first use here). - remote target routine remote_follow_fork, which just sends the 'D;pid' detach packet to detach the new fork child cleanly. We can't just call target_detach because the data structures for the forked child have not been allocated on the host side. Tested on x64 Ubuntu Lucid, native, remote, extended-remote. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Implement return value, rename argument 'event_child' to 'event_lwp', handle PTRACE_EVENT_FORK, call internal_error for unrecognized event. (linux_low_ptrace_options): New function. (linux_low_filter_event): Call linux_low_ptrace_options, use different argument fo linux_enable_event_reporting, use return value from handle_extended_wait. (extended_event_reported): New function. (linux_wait_1): Call extended_event_reported and set status to report fork events. (linux_write_memory): Add pid to debug message. (reset_lwp_ptrace_options_callback): New function. (linux_handle_new_gdb_connection): New function. (linux_target_ops): Initialize new structure member. * linux-low.h (struct lwp_info) <waitstatus>: New member. * lynx-low.c: Initialize new structure member. * remote-utils.c (prepare_resume_reply): Implement stop reason "fork" for "T" stop message. * server.c (handle_query): Call handle_new_gdb_connection. * server.h (report_fork_events): Declare global flag. * target.h (struct target_ops) <handle_new_gdb_connection>: New member. (target_handle_new_gdb_connection): New macro. * win32-low.c: Initialize new structure member. gdb/ChangeLog: * linux-nat.c (linux_nat_ptrace_options): New function. (linux_init_ptrace, wait_lwp, linux_nat_filter_event): Call linux_nat_ptrace_options and use different argument to linux_enable_event_reporting. (_initialize_linux_nat): Delete call to linux_ptrace_set_additional_flags. * nat/linux-ptrace.c (current_ptrace_options): Rename to supported_ptrace_options. (additional_flags): Delete variable. (linux_check_ptrace_features): Use supported_ptrace_options. (linux_test_for_tracesysgood, linux_test_for_tracefork): Likewise, and remove additional_flags check. (linux_enable_event_reporting): Change 'attached' argument to 'options'. Use supported_ptrace_options. (ptrace_supports_feature): Change comment. Use supported_ptrace_options. (linux_ptrace_set_additional_flags): Delete function. * nat/linux-ptrace.h (linux_ptrace_set_additional_flags): Delete function prototype. * remote.c (remote_fork_event_p): New function. (remote_detach_pid): New function. (remote_detach_1): Call remote_detach_pid, don't mourn inferior if doing detach-on-fork. (remote_follow_fork): New function. (remote_parse_stop_reply): Handle new "T" stop reason "fork". (remote_pid_to_str): Print "process" strings for pid/0/0 ptids. (init_extended_remote_ops): Initialize to_follow_fork.
2015-05-12 18:52:43 +02:00
}
int
linux_process_target::handle_monitor_command (char *mon)
{
#ifdef USE_THREAD_DB
return thread_db_handle_monitor_command (mon);
#else
return 0;
#endif
}
int
linux_process_target::core_of_thread (ptid_t ptid)
{
return linux_common_core_of_thread (ptid);
}
bool
linux_process_target::supports_disable_randomization ()
* inferior.h (disable_randomization): Declare. * infrun.c (disable_randomization): New global variable. (show_disable_randomization): New function. (set_disable_randomization): Likewise. (_initialize_infrun): Install set/show disable-randomization commands. * linux-nat.c (disable_randomization): Remove. (show_disable_randomization): Likewise. (set_disable_randomization): Likewise. (_initialize_linux_nat): No longer install set/show disable-randomization commands here. (linux_nat_supports_disable_randomization): New function. (linux_nat_add_target): Install it. * remote.c (PACKET_QDisableRandomization): New enum value. (remote_protocol_packets): Support QDisableRandomization. (_initialize_remote): Likewise. (remote_supports_disable_randomization): New function. (init_remote_ops): Install it. (extended_remote_supports_disable_randomization): New function. (init_extended_remote_ops): Install it. (extended_remote_disable_randomization): New function. (extended_remote_create_inferior_1): Call it. * target.h (struct target_ops): Add to_supports_disable_randomization. (target_supports_disable_randomization): Add prototype. * target.c (target_supports_disable_randomization): New function. (find_default_supports_disable_randomization): Likewise. (init_dummy_target): Install it. doc/ * gdb.texinfo (Starting your Program): "set disable-randomization" is no longer Linux-specific. (Remote Configuration): Document "set remote disable-randomization-packet". (General Query Packets): Document "QDisableRandomization" packet and add it to "qSupported" list. gdbserver/ * configure.ac: Check support for personality routine. * configure: Regenerate. * config.in: Likewise. * linux-low.c: Include <sys/personality.h>. Define ADDR_NO_RANDOMIZE if necessary. (linux_create_inferior): Disable address space randomization when forking inferior, if requested. (linux_supports_disable_randomization): New function. (linux_target_ops): Install it. * server.h (disable_randomization): Declare. * server.c (disable_randomization): New global variable. (handle_general_set): Handle QDisableRandomization. (handle_query): Likewise for qSupported. (main): Support --disable-randomization and --no-disable-randomization command line arguments. * target.h (struct target_ops): Add supports_disable_randomization. (target_supports_disable_randomization): New macro.
2011-10-07 14:06:48 +02:00
{
#ifdef HAVE_PERSONALITY
return true;
* inferior.h (disable_randomization): Declare. * infrun.c (disable_randomization): New global variable. (show_disable_randomization): New function. (set_disable_randomization): Likewise. (_initialize_infrun): Install set/show disable-randomization commands. * linux-nat.c (disable_randomization): Remove. (show_disable_randomization): Likewise. (set_disable_randomization): Likewise. (_initialize_linux_nat): No longer install set/show disable-randomization commands here. (linux_nat_supports_disable_randomization): New function. (linux_nat_add_target): Install it. * remote.c (PACKET_QDisableRandomization): New enum value. (remote_protocol_packets): Support QDisableRandomization. (_initialize_remote): Likewise. (remote_supports_disable_randomization): New function. (init_remote_ops): Install it. (extended_remote_supports_disable_randomization): New function. (init_extended_remote_ops): Install it. (extended_remote_disable_randomization): New function. (extended_remote_create_inferior_1): Call it. * target.h (struct target_ops): Add to_supports_disable_randomization. (target_supports_disable_randomization): Add prototype. * target.c (target_supports_disable_randomization): New function. (find_default_supports_disable_randomization): Likewise. (init_dummy_target): Install it. doc/ * gdb.texinfo (Starting your Program): "set disable-randomization" is no longer Linux-specific. (Remote Configuration): Document "set remote disable-randomization-packet". (General Query Packets): Document "QDisableRandomization" packet and add it to "qSupported" list. gdbserver/ * configure.ac: Check support for personality routine. * configure: Regenerate. * config.in: Likewise. * linux-low.c: Include <sys/personality.h>. Define ADDR_NO_RANDOMIZE if necessary. (linux_create_inferior): Disable address space randomization when forking inferior, if requested. (linux_supports_disable_randomization): New function. (linux_target_ops): Install it. * server.h (disable_randomization): Declare. * server.c (disable_randomization): New global variable. (handle_general_set): Handle QDisableRandomization. (handle_query): Likewise for qSupported. (main): Support --disable-randomization and --no-disable-randomization command line arguments. * target.h (struct target_ops): Add supports_disable_randomization. (target_supports_disable_randomization): New macro.
2011-10-07 14:06:48 +02:00
#else
return false;
* inferior.h (disable_randomization): Declare. * infrun.c (disable_randomization): New global variable. (show_disable_randomization): New function. (set_disable_randomization): Likewise. (_initialize_infrun): Install set/show disable-randomization commands. * linux-nat.c (disable_randomization): Remove. (show_disable_randomization): Likewise. (set_disable_randomization): Likewise. (_initialize_linux_nat): No longer install set/show disable-randomization commands here. (linux_nat_supports_disable_randomization): New function. (linux_nat_add_target): Install it. * remote.c (PACKET_QDisableRandomization): New enum value. (remote_protocol_packets): Support QDisableRandomization. (_initialize_remote): Likewise. (remote_supports_disable_randomization): New function. (init_remote_ops): Install it. (extended_remote_supports_disable_randomization): New function. (init_extended_remote_ops): Install it. (extended_remote_disable_randomization): New function. (extended_remote_create_inferior_1): Call it. * target.h (struct target_ops): Add to_supports_disable_randomization. (target_supports_disable_randomization): Add prototype. * target.c (target_supports_disable_randomization): New function. (find_default_supports_disable_randomization): Likewise. (init_dummy_target): Install it. doc/ * gdb.texinfo (Starting your Program): "set disable-randomization" is no longer Linux-specific. (Remote Configuration): Document "set remote disable-randomization-packet". (General Query Packets): Document "QDisableRandomization" packet and add it to "qSupported" list. gdbserver/ * configure.ac: Check support for personality routine. * configure: Regenerate. * config.in: Likewise. * linux-low.c: Include <sys/personality.h>. Define ADDR_NO_RANDOMIZE if necessary. (linux_create_inferior): Disable address space randomization when forking inferior, if requested. (linux_supports_disable_randomization): New function. (linux_target_ops): Install it. * server.h (disable_randomization): Declare. * server.c (disable_randomization): New global variable. (handle_general_set): Handle QDisableRandomization. (handle_query): Likewise for qSupported. (main): Support --disable-randomization and --no-disable-randomization command line arguments. * target.h (struct target_ops): Add supports_disable_randomization. (target_supports_disable_randomization): New macro.
2011-10-07 14:06:48 +02:00
#endif
}
bool
linux_process_target::supports_agent ()
{
return true;
}
bool
linux_process_target::supports_range_stepping ()
range stepping: gdbserver (x86 GNU/Linux) This patch adds support for range stepping to GDBserver, teaching it about vCont;r. It'd be easy to enable this for all hardware single-step targets without needing the linux_target_ops hook, however, at least PPC needs special care, due to the fact that PPC atomic sequences can't be hardware single-stepped through, a thing which GDBserver doesn't know about. So this leaves the support limited to x86/x86_64. gdb/ 2013-05-23 Pedro Alves <palves@redhat.com> * NEWS: Mention GDBserver range stepping support. gdb/gdbserver/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * linux-low.c (lwp_in_step_range): New function. (linux_wait_1): If the thread was range stepping and stopped outside the stepping range, report the stop to GDB. Otherwise, continue stepping. Add range stepping debug output. (linux_set_resume_request): Copy the step range from the resume request to the lwp. (linux_supports_range_stepping): New. (linux_target_ops) <supports_range_stepping>: Set to linux_supports_range_stepping. * linux-low.h (struct linux_target_ops) <supports_range_stepping>: New field. (struct lwp_info) <step_range_start, step_range_end>: New fields. * linux-x86-low.c (x86_supports_range_stepping): New. (the_low_target) <supports_range_stepping>: Set to x86_supports_range_stepping. * server.c (handle_v_cont): Handle 'r' action. (handle_v_requests): Append ";r" if the target supports range stepping. * target.h (struct thread_resume) <step_range_start, step_range_end>: New fields. (struct target_ops) <supports_range_stepping>: New field. (target_supports_range_stepping): New macro.
2013-05-23 19:17:50 +02:00
{
gdbserver/linux-low: turn 'supports_software_single_step' and 'get_next_pcs' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Remove the 'supports_software_single_step' linux target op and let the concrete linux target define it by overriding the op in process_stratum_target. Turn the 'get_next_pcs' linux target op into a method of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <supports_software_single_step>: Remove. <low_get_next_pcs>: Declare. * linux-low.cc (can_software_single_step): Remove. (linux_process_target::low_get_next_pcs): Define. (linux_process_target::supports_software_single_step): Remove. Update the callers below. (linux_process_target::handle_extended_wait) (linux_process_target::wait_1) (linux_process_target::install_software_single_step_breakpoints) (linux_process_target::single_step) (linux_process_target::thread_needs_step_over) (linux_process_target::proceed_one_lwp) (linux_process_target::supports_range_stepping) * linux-x86-low.cc (the_low_target): Remove the op field. * linux-aarch64-low.cc (the_low_target): Ditto. * linux-bfin-low.cc (the_low_target): Ditto. * linux-cris-low.cc (the_low_target): Ditto. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-mips-low.cc (the_low_target): Ditto. * linux-nios2-low.cc (the_low_target): Ditto. * linux-ppc-low.cc (the_low_target): Ditto. * linux-riscv-low.cc (the_low_target): Ditto. * linux-s390-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-sparc-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto. * linux-arm-low.cc (class arm_target) <low_get_next_pcs> <supports_software_single_step>: Declare. (arm_target::supports_software_single_step): Define. (arm_gdbserver_get_next_pcs): Turn into... (arm_target::low_get_next_pcs): ...this. (the_low_target): Remove the op field.
2020-04-02 15:11:26 +02:00
if (supports_software_single_step ())
return true;
range stepping: gdbserver (x86 GNU/Linux) This patch adds support for range stepping to GDBserver, teaching it about vCont;r. It'd be easy to enable this for all hardware single-step targets without needing the linux_target_ops hook, however, at least PPC needs special care, due to the fact that PPC atomic sequences can't be hardware single-stepped through, a thing which GDBserver doesn't know about. So this leaves the support limited to x86/x86_64. gdb/ 2013-05-23 Pedro Alves <palves@redhat.com> * NEWS: Mention GDBserver range stepping support. gdb/gdbserver/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * linux-low.c (lwp_in_step_range): New function. (linux_wait_1): If the thread was range stepping and stopped outside the stepping range, report the stop to GDB. Otherwise, continue stepping. Add range stepping debug output. (linux_set_resume_request): Copy the step range from the resume request to the lwp. (linux_supports_range_stepping): New. (linux_target_ops) <supports_range_stepping>: Set to linux_supports_range_stepping. * linux-low.h (struct linux_target_ops) <supports_range_stepping>: New field. (struct lwp_info) <step_range_start, step_range_end>: New fields. * linux-x86-low.c (x86_supports_range_stepping): New. (the_low_target) <supports_range_stepping>: Set to x86_supports_range_stepping. * server.c (handle_v_cont): Handle 'r' action. (handle_v_requests): Append ";r" if the target supports range stepping. * target.h (struct thread_resume) <step_range_start, step_range_end>: New fields. (struct target_ops) <supports_range_stepping>: New field. (target_supports_range_stepping): New macro.
2013-05-23 19:17:50 +02:00
return low_supports_range_stepping ();
}
bool
linux_process_target::low_supports_range_stepping ()
{
return false;
range stepping: gdbserver (x86 GNU/Linux) This patch adds support for range stepping to GDBserver, teaching it about vCont;r. It'd be easy to enable this for all hardware single-step targets without needing the linux_target_ops hook, however, at least PPC needs special care, due to the fact that PPC atomic sequences can't be hardware single-stepped through, a thing which GDBserver doesn't know about. So this leaves the support limited to x86/x86_64. gdb/ 2013-05-23 Pedro Alves <palves@redhat.com> * NEWS: Mention GDBserver range stepping support. gdb/gdbserver/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * linux-low.c (lwp_in_step_range): New function. (linux_wait_1): If the thread was range stepping and stopped outside the stepping range, report the stop to GDB. Otherwise, continue stepping. Add range stepping debug output. (linux_set_resume_request): Copy the step range from the resume request to the lwp. (linux_supports_range_stepping): New. (linux_target_ops) <supports_range_stepping>: Set to linux_supports_range_stepping. * linux-low.h (struct linux_target_ops) <supports_range_stepping>: New field. (struct lwp_info) <step_range_start, step_range_end>: New fields. * linux-x86-low.c (x86_supports_range_stepping): New. (the_low_target) <supports_range_stepping>: Set to x86_supports_range_stepping. * server.c (handle_v_cont): Handle 'r' action. (handle_v_requests): Append ";r" if the target supports range stepping. * target.h (struct thread_resume) <step_range_start, step_range_end>: New fields. (struct target_ops) <supports_range_stepping>: New field. (target_supports_range_stepping): New macro.
2013-05-23 19:17:50 +02:00
}
bool
linux_process_target::supports_pid_to_exec_file ()
{
return true;
}
char *
linux_process_target::pid_to_exec_file (int pid)
{
return linux_proc_pid_to_exec_file (pid);
}
bool
linux_process_target::supports_multifs ()
{
return true;
}
int
linux_process_target::multifs_open (int pid, const char *filename,
int flags, mode_t mode)
{
return linux_mntns_open_cloexec (pid, filename, flags, mode);
}
int
linux_process_target::multifs_unlink (int pid, const char *filename)
{
return linux_mntns_unlink (pid, filename);
}
ssize_t
linux_process_target::multifs_readlink (int pid, const char *filename,
char *buf, size_t bufsiz)
{
return linux_mntns_readlink (pid, filename, buf, bufsiz);
}
#if defined PT_GETDSBT || defined PTRACE_GETFDPIC
struct target_loadseg
{
/* Core address to which the segment is mapped. */
Elf32_Addr addr;
/* VMA recorded in the program header. */
Elf32_Addr p_vaddr;
/* Size of this segment in memory. */
Elf32_Word p_memsz;
};
# if defined PT_GETDSBT
struct target_loadmap
{
/* Protocol version number, must be zero. */
Elf32_Word version;
/* Pointer to the DSBT table, its size, and the DSBT index. */
unsigned *dsbt_table;
unsigned dsbt_size, dsbt_index;
/* Number of segments in this map. */
Elf32_Word nsegs;
/* The actual memory map. */
struct target_loadseg segs[/*nsegs*/];
};
# define LINUX_LOADMAP PT_GETDSBT
# define LINUX_LOADMAP_EXEC PTRACE_GETDSBT_EXEC
# define LINUX_LOADMAP_INTERP PTRACE_GETDSBT_INTERP
# else
struct target_loadmap
{
/* Protocol version number, must be zero. */
Elf32_Half version;
/* Number of segments in this map. */
Elf32_Half nsegs;
/* The actual memory map. */
struct target_loadseg segs[/*nsegs*/];
};
# define LINUX_LOADMAP PTRACE_GETFDPIC
# define LINUX_LOADMAP_EXEC PTRACE_GETFDPIC_EXEC
# define LINUX_LOADMAP_INTERP PTRACE_GETFDPIC_INTERP
# endif
bool
linux_process_target::supports_read_loadmap ()
{
return true;
}
int
linux_process_target::read_loadmap (const char *annex, CORE_ADDR offset,
unsigned char *myaddr, unsigned int len)
{
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
int pid = lwpid_of (current_thread);
int addr = -1;
struct target_loadmap *data = NULL;
unsigned int actual_length, copy_length;
if (strcmp (annex, "exec") == 0)
addr = (int) LINUX_LOADMAP_EXEC;
else if (strcmp (annex, "interp") == 0)
addr = (int) LINUX_LOADMAP_INTERP;
else
return -1;
if (ptrace (LINUX_LOADMAP, pid, addr, &data) != 0)
return -1;
if (data == NULL)
return -1;
actual_length = sizeof (struct target_loadmap)
+ sizeof (struct target_loadseg) * data->nsegs;
if (offset < 0 || offset > actual_length)
return -1;
copy_length = actual_length - offset < len ? actual_length - offset : len;
memcpy (myaddr, (char *) data + offset, copy_length);
return copy_length;
}
#endif /* defined PT_GETDSBT || defined PTRACE_GETFDPIC */
bool
linux_process_target::supports_catch_syscall ()
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
{
gdbserver/linux-low: turn 'get_syscall_trapinfo' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_syscall_trapinfo' linux target op into a method of process_stratum_target. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <get_syscall_trapinfo> <gdb_catch_this_syscall> <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. * linux-low.cc (get_syscall_trapinfo): Turn into... (linux_process_target::get_syscall_trapinfo): ...this. (linux_process_target::low_get_syscall_trapinfo): Define. (gdb_catch_this_syscall_p): Turn into... (linux_process_target::gdb_catch_this_syscall): ...this. (linux_process_target::low_supports_catch_syscall): Define. Update the callers below. (linux_process_target::wait_1) (linux_process_target::supports_catch_syscall) * linux-x86-low.cc (class x86_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (x86_target::low_supports_catch_syscall): Define. (x86_get_syscall_trapinfo): Turn into... (x86_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (aarch64_target::low_supports_catch_syscall): Define. (aarch64_get_syscall_trapinfo): Turn into... (aarch64_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (class arm_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (arm_target::low_supports_catch_syscall): Define. (arm_get_syscall_trapinfo): Turn into... (arm_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (the_low_target): Remove the op field. * linux-s390-low.cc (the_low_target): Remove the op field.
2020-04-02 15:11:31 +02:00
return (low_supports_catch_syscall ()
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
&& linux_supports_tracesysgood ());
}
gdbserver/linux-low: turn 'get_syscall_trapinfo' into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_syscall_trapinfo' linux target op into a method of process_stratum_target. * linux-low.h (struct linux_target_ops): Remove the op. (class linux_process_target) <get_syscall_trapinfo> <gdb_catch_this_syscall> <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. * linux-low.cc (get_syscall_trapinfo): Turn into... (linux_process_target::get_syscall_trapinfo): ...this. (linux_process_target::low_get_syscall_trapinfo): Define. (gdb_catch_this_syscall_p): Turn into... (linux_process_target::gdb_catch_this_syscall): ...this. (linux_process_target::low_supports_catch_syscall): Define. Update the callers below. (linux_process_target::wait_1) (linux_process_target::supports_catch_syscall) * linux-x86-low.cc (class x86_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (x86_target::low_supports_catch_syscall): Define. (x86_get_syscall_trapinfo): Turn into... (x86_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-aarch64-low.cc (class aarch64_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (aarch64_target::low_supports_catch_syscall): Define. (aarch64_get_syscall_trapinfo): Turn into... (aarch64_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-arm-low.cc (class arm_target) <low_supports_catch_syscall> <low_get_syscall_trapinfo>: Declare. (arm_target::low_supports_catch_syscall): Define. (arm_get_syscall_trapinfo): Turn into... (arm_target::low_get_syscall_trapinfo): ...this. (the_low_target): Remove the op field. * linux-ppc-low.cc (the_low_target): Remove the op field. * linux-s390-low.cc (the_low_target): Remove the op field.
2020-04-02 15:11:31 +02:00
bool
linux_process_target::low_supports_catch_syscall ()
{
return false;
}
CORE_ADDR
linux_process_target::read_pc (regcache *regcache)
gdb/gdbserver/ * server.h (LONGEST): New. (struct thread_info) <while_stepping>: New field. (unpack_varlen_hex, xrealloc, pulongest, plongest, phex_nz): Declare. (initialize_tracepoint, handle_tracepoint_general_set) (handle_tracepoint_query, tracepoint_finished_step) (tracepoint_was_hit, release_while_stepping_state_list): (current_traceframe): Declare. * server.c (handle_general_set): Handle tracepoint packets. (read_memory): New. (write_memory): New. (handle_search_memory_1): Use read_memory. (handle_query): Report support for conditional tracepoints, trace state variables, and tracepoint sources. Handle tracepoint queries. (main): Initialize the tracepoints module. (process_serial_event): Handle traceframe reads/writes. * linux-low.c (handle_tracepoints): New. (linux_wait_1): Call it. (linux_resume_one_lwp): Handle while-stepping. (linux_supports_tracepoints, linux_read_pc, linux_write_pc): New. (linux_target_ops): Install them. * linux-low.h (struct linux_target_ops) <supports_tracepoints>: New field. * linux-x86-low.c (x86_supports_tracepoints): New. (the_low_target). Install it. * mem-break.h (delete_breakpoint): Declare. * mem-break.c (delete_breakpoint): Make external. * target.h (struct target_ops): Add `supports_tracepoints', `read_pc', and `write_pc' fields. (target_supports_tracepoints): Define. * utils.c (xrealloc, decimal2str, pulongest, plongest, thirty_two) (phex_nz): New. * regcache.h (struct regcache) <registers_owned>: New field. (init_register_cache, regcache_cpy): Declare. (regcache_read_pc, regcache_write_pc): Declare. (register_cache_size): Declare. (supply_regblock): Declare. * regcache.c (init_register_cache): New. (new_register_cache): Use it. (regcache_cpy): New. (register_cache_size): New. (supply_regblock): New. (regcache_read_pc, regcache_write_pc): New. * tracepoint.c: New. * Makefile.in (OBS): Add tracepoint.o. (tracepoint.o): New rule. gdb/ * regformats/regdat.sh: Include server.h. Don't include regcache.h.
2010-04-09 05:40:00 +02:00
{
gdbserver/linux-low: turn 'get_pc' and 'set_pc' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_pc' and 'set_pc' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. * linux-low.cc (supports_breakpoints): Turn into... (linux_process_target::low_supports_breakpoints): ...this. (linux_process_target::low_get_pc): Define. (linux_process_target::low_set_pc): Define. Update the callers below. (linux_process_target::get_pc) (linux_process_target::save_stop_reason) (linux_process_target::maybe_move_out_of_jump_pad) (linux_process_target::wait_1) (linux_process_target::resume_one_lwp_throw) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (linux_process_target::read_pc) (linux_process_target::write_pc) * linux-x86-low.cc (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (x86_target::low_supports_breakpoints): Define. (x86_get_pc): Turn into... (x86_target::low_get_pc): ...this. (x86_set_pc): Turn into... (x86_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (arm_target::low_supports_breakpoints) (arm_target::low_get_pc) (arm_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (bfin_target::low_supports_breakpoints) (bfin_target::low_get_pc) (bfin_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (cris_target::low_supports_breakpoints) (cris_target::low_get_pc) (cris_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (crisv32_target::low_supports_breakpoints) (crisv32_target::low_get_pc) (crisv32_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m32r_target::low_supports_breakpoints) (m32r_target::low_get_pc) (m32r_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m68k_target::low_supports_breakpoints) (m68k_target::low_get_pc) (m68k_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (nios2_target::low_supports_breakpoints) (nios2_target::low_get_pc) (nios2_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (sh_target::low_supports_breakpoints) (sh_target::low_get_pc) (sh_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (xtensa_target::low_supports_breakpoints) (xtensa_target::low_get_pc) (xtensa_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_supports_breakpoints> <low_get_pc>: Declare. (sparc_target::low_supports_breakpoints) (sparc_target::low_get_pc): Define. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tile_target::low_supports_breakpoints) (tile_target::low_get_pc) (tile_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (aarch64_target::low_supports_breakpoints): Define. (aarch64_get_pc): Turn into... (aarch64_target::low_get_pc): ...this. (aarch64_set_pc): Turn into... (aarch64_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (mips_target::low_supports_breakpoints): Define. (mips_get_pc): Turn into... (mips_target::low_get_pc): ...this. (mips_set_pc): Turn into... (mips_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (ppc_target::low_supports_breakpoints): Define. (ppc_get_pc): Turn into... (ppc_target::low_get_pc): ...this. (ppc_set_pc): Turn into... (ppc_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (riscv_target::low_supports_breakpoints): Define. (riscv_get_pc): Turn into... (riscv_target::low_get_pc): ...this. (riscv_set_pc): Turn into... (riscv_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (s390_target::low_supports_breakpoints): Define. (s390_get_pc): Turn into... (s390_target::low_get_pc): ...this. (s390_set_pc): Turn into... (s390_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tic6x_target::low_supports_breakpoints): Define. (tic6x_get_pc): Turn into... (tic6x_target::low_get_pc): ...this. (tic6x_set_pc): Turn into... (tic6x_target::low_set_pc): ...this. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
if (!low_supports_breakpoints ())
gdb/gdbserver/ * server.h (LONGEST): New. (struct thread_info) <while_stepping>: New field. (unpack_varlen_hex, xrealloc, pulongest, plongest, phex_nz): Declare. (initialize_tracepoint, handle_tracepoint_general_set) (handle_tracepoint_query, tracepoint_finished_step) (tracepoint_was_hit, release_while_stepping_state_list): (current_traceframe): Declare. * server.c (handle_general_set): Handle tracepoint packets. (read_memory): New. (write_memory): New. (handle_search_memory_1): Use read_memory. (handle_query): Report support for conditional tracepoints, trace state variables, and tracepoint sources. Handle tracepoint queries. (main): Initialize the tracepoints module. (process_serial_event): Handle traceframe reads/writes. * linux-low.c (handle_tracepoints): New. (linux_wait_1): Call it. (linux_resume_one_lwp): Handle while-stepping. (linux_supports_tracepoints, linux_read_pc, linux_write_pc): New. (linux_target_ops): Install them. * linux-low.h (struct linux_target_ops) <supports_tracepoints>: New field. * linux-x86-low.c (x86_supports_tracepoints): New. (the_low_target). Install it. * mem-break.h (delete_breakpoint): Declare. * mem-break.c (delete_breakpoint): Make external. * target.h (struct target_ops): Add `supports_tracepoints', `read_pc', and `write_pc' fields. (target_supports_tracepoints): Define. * utils.c (xrealloc, decimal2str, pulongest, plongest, thirty_two) (phex_nz): New. * regcache.h (struct regcache) <registers_owned>: New field. (init_register_cache, regcache_cpy): Declare. (regcache_read_pc, regcache_write_pc): Declare. (register_cache_size): Declare. (supply_regblock): Declare. * regcache.c (init_register_cache): New. (new_register_cache): Use it. (regcache_cpy): New. (register_cache_size): New. (supply_regblock): New. (regcache_read_pc, regcache_write_pc): New. * tracepoint.c: New. * Makefile.in (OBS): Add tracepoint.o. (tracepoint.o): New rule. gdb/ * regformats/regdat.sh: Include server.h. Don't include regcache.h.
2010-04-09 05:40:00 +02:00
return 0;
gdbserver/linux-low: turn 'get_pc' and 'set_pc' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_pc' and 'set_pc' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. * linux-low.cc (supports_breakpoints): Turn into... (linux_process_target::low_supports_breakpoints): ...this. (linux_process_target::low_get_pc): Define. (linux_process_target::low_set_pc): Define. Update the callers below. (linux_process_target::get_pc) (linux_process_target::save_stop_reason) (linux_process_target::maybe_move_out_of_jump_pad) (linux_process_target::wait_1) (linux_process_target::resume_one_lwp_throw) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (linux_process_target::read_pc) (linux_process_target::write_pc) * linux-x86-low.cc (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (x86_target::low_supports_breakpoints): Define. (x86_get_pc): Turn into... (x86_target::low_get_pc): ...this. (x86_set_pc): Turn into... (x86_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (arm_target::low_supports_breakpoints) (arm_target::low_get_pc) (arm_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (bfin_target::low_supports_breakpoints) (bfin_target::low_get_pc) (bfin_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (cris_target::low_supports_breakpoints) (cris_target::low_get_pc) (cris_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (crisv32_target::low_supports_breakpoints) (crisv32_target::low_get_pc) (crisv32_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m32r_target::low_supports_breakpoints) (m32r_target::low_get_pc) (m32r_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m68k_target::low_supports_breakpoints) (m68k_target::low_get_pc) (m68k_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (nios2_target::low_supports_breakpoints) (nios2_target::low_get_pc) (nios2_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (sh_target::low_supports_breakpoints) (sh_target::low_get_pc) (sh_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (xtensa_target::low_supports_breakpoints) (xtensa_target::low_get_pc) (xtensa_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_supports_breakpoints> <low_get_pc>: Declare. (sparc_target::low_supports_breakpoints) (sparc_target::low_get_pc): Define. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tile_target::low_supports_breakpoints) (tile_target::low_get_pc) (tile_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (aarch64_target::low_supports_breakpoints): Define. (aarch64_get_pc): Turn into... (aarch64_target::low_get_pc): ...this. (aarch64_set_pc): Turn into... (aarch64_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (mips_target::low_supports_breakpoints): Define. (mips_get_pc): Turn into... (mips_target::low_get_pc): ...this. (mips_set_pc): Turn into... (mips_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (ppc_target::low_supports_breakpoints): Define. (ppc_get_pc): Turn into... (ppc_target::low_get_pc): ...this. (ppc_set_pc): Turn into... (ppc_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (riscv_target::low_supports_breakpoints): Define. (riscv_get_pc): Turn into... (riscv_target::low_get_pc): ...this. (riscv_set_pc): Turn into... (riscv_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (s390_target::low_supports_breakpoints): Define. (s390_get_pc): Turn into... (s390_target::low_get_pc): ...this. (s390_set_pc): Turn into... (s390_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tic6x_target::low_supports_breakpoints): Define. (tic6x_get_pc): Turn into... (tic6x_target::low_get_pc): ...this. (tic6x_set_pc): Turn into... (tic6x_target::low_set_pc): ...this. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
return low_get_pc (regcache);
gdb/gdbserver/ * server.h (LONGEST): New. (struct thread_info) <while_stepping>: New field. (unpack_varlen_hex, xrealloc, pulongest, plongest, phex_nz): Declare. (initialize_tracepoint, handle_tracepoint_general_set) (handle_tracepoint_query, tracepoint_finished_step) (tracepoint_was_hit, release_while_stepping_state_list): (current_traceframe): Declare. * server.c (handle_general_set): Handle tracepoint packets. (read_memory): New. (write_memory): New. (handle_search_memory_1): Use read_memory. (handle_query): Report support for conditional tracepoints, trace state variables, and tracepoint sources. Handle tracepoint queries. (main): Initialize the tracepoints module. (process_serial_event): Handle traceframe reads/writes. * linux-low.c (handle_tracepoints): New. (linux_wait_1): Call it. (linux_resume_one_lwp): Handle while-stepping. (linux_supports_tracepoints, linux_read_pc, linux_write_pc): New. (linux_target_ops): Install them. * linux-low.h (struct linux_target_ops) <supports_tracepoints>: New field. * linux-x86-low.c (x86_supports_tracepoints): New. (the_low_target). Install it. * mem-break.h (delete_breakpoint): Declare. * mem-break.c (delete_breakpoint): Make external. * target.h (struct target_ops): Add `supports_tracepoints', `read_pc', and `write_pc' fields. (target_supports_tracepoints): Define. * utils.c (xrealloc, decimal2str, pulongest, plongest, thirty_two) (phex_nz): New. * regcache.h (struct regcache) <registers_owned>: New field. (init_register_cache, regcache_cpy): Declare. (regcache_read_pc, regcache_write_pc): Declare. (register_cache_size): Declare. (supply_regblock): Declare. * regcache.c (init_register_cache): New. (new_register_cache): Use it. (regcache_cpy): New. (register_cache_size): New. (supply_regblock): New. (regcache_read_pc, regcache_write_pc): New. * tracepoint.c: New. * Makefile.in (OBS): Add tracepoint.o. (tracepoint.o): New rule. gdb/ * regformats/regdat.sh: Include server.h. Don't include regcache.h.
2010-04-09 05:40:00 +02:00
}
void
linux_process_target::write_pc (regcache *regcache, CORE_ADDR pc)
gdb/gdbserver/ * server.h (LONGEST): New. (struct thread_info) <while_stepping>: New field. (unpack_varlen_hex, xrealloc, pulongest, plongest, phex_nz): Declare. (initialize_tracepoint, handle_tracepoint_general_set) (handle_tracepoint_query, tracepoint_finished_step) (tracepoint_was_hit, release_while_stepping_state_list): (current_traceframe): Declare. * server.c (handle_general_set): Handle tracepoint packets. (read_memory): New. (write_memory): New. (handle_search_memory_1): Use read_memory. (handle_query): Report support for conditional tracepoints, trace state variables, and tracepoint sources. Handle tracepoint queries. (main): Initialize the tracepoints module. (process_serial_event): Handle traceframe reads/writes. * linux-low.c (handle_tracepoints): New. (linux_wait_1): Call it. (linux_resume_one_lwp): Handle while-stepping. (linux_supports_tracepoints, linux_read_pc, linux_write_pc): New. (linux_target_ops): Install them. * linux-low.h (struct linux_target_ops) <supports_tracepoints>: New field. * linux-x86-low.c (x86_supports_tracepoints): New. (the_low_target). Install it. * mem-break.h (delete_breakpoint): Declare. * mem-break.c (delete_breakpoint): Make external. * target.h (struct target_ops): Add `supports_tracepoints', `read_pc', and `write_pc' fields. (target_supports_tracepoints): Define. * utils.c (xrealloc, decimal2str, pulongest, plongest, thirty_two) (phex_nz): New. * regcache.h (struct regcache) <registers_owned>: New field. (init_register_cache, regcache_cpy): Declare. (regcache_read_pc, regcache_write_pc): Declare. (register_cache_size): Declare. (supply_regblock): Declare. * regcache.c (init_register_cache): New. (new_register_cache): Use it. (regcache_cpy): New. (register_cache_size): New. (supply_regblock): New. (regcache_read_pc, regcache_write_pc): New. * tracepoint.c: New. * Makefile.in (OBS): Add tracepoint.o. (tracepoint.o): New rule. gdb/ * regformats/regdat.sh: Include server.h. Don't include regcache.h.
2010-04-09 05:40:00 +02:00
{
gdbserver/linux-low: turn 'get_pc' and 'set_pc' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_pc' and 'set_pc' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. * linux-low.cc (supports_breakpoints): Turn into... (linux_process_target::low_supports_breakpoints): ...this. (linux_process_target::low_get_pc): Define. (linux_process_target::low_set_pc): Define. Update the callers below. (linux_process_target::get_pc) (linux_process_target::save_stop_reason) (linux_process_target::maybe_move_out_of_jump_pad) (linux_process_target::wait_1) (linux_process_target::resume_one_lwp_throw) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (linux_process_target::read_pc) (linux_process_target::write_pc) * linux-x86-low.cc (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (x86_target::low_supports_breakpoints): Define. (x86_get_pc): Turn into... (x86_target::low_get_pc): ...this. (x86_set_pc): Turn into... (x86_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (arm_target::low_supports_breakpoints) (arm_target::low_get_pc) (arm_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (bfin_target::low_supports_breakpoints) (bfin_target::low_get_pc) (bfin_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (cris_target::low_supports_breakpoints) (cris_target::low_get_pc) (cris_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (crisv32_target::low_supports_breakpoints) (crisv32_target::low_get_pc) (crisv32_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m32r_target::low_supports_breakpoints) (m32r_target::low_get_pc) (m32r_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m68k_target::low_supports_breakpoints) (m68k_target::low_get_pc) (m68k_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (nios2_target::low_supports_breakpoints) (nios2_target::low_get_pc) (nios2_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (sh_target::low_supports_breakpoints) (sh_target::low_get_pc) (sh_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (xtensa_target::low_supports_breakpoints) (xtensa_target::low_get_pc) (xtensa_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_supports_breakpoints> <low_get_pc>: Declare. (sparc_target::low_supports_breakpoints) (sparc_target::low_get_pc): Define. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tile_target::low_supports_breakpoints) (tile_target::low_get_pc) (tile_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (aarch64_target::low_supports_breakpoints): Define. (aarch64_get_pc): Turn into... (aarch64_target::low_get_pc): ...this. (aarch64_set_pc): Turn into... (aarch64_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (mips_target::low_supports_breakpoints): Define. (mips_get_pc): Turn into... (mips_target::low_get_pc): ...this. (mips_set_pc): Turn into... (mips_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (ppc_target::low_supports_breakpoints): Define. (ppc_get_pc): Turn into... (ppc_target::low_get_pc): ...this. (ppc_set_pc): Turn into... (ppc_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (riscv_target::low_supports_breakpoints): Define. (riscv_get_pc): Turn into... (riscv_target::low_get_pc): ...this. (riscv_set_pc): Turn into... (riscv_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (s390_target::low_supports_breakpoints): Define. (s390_get_pc): Turn into... (s390_target::low_get_pc): ...this. (s390_set_pc): Turn into... (s390_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tic6x_target::low_supports_breakpoints): Define. (tic6x_get_pc): Turn into... (tic6x_target::low_get_pc): ...this. (tic6x_set_pc): Turn into... (tic6x_target::low_set_pc): ...this. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
gdb_assert (low_supports_breakpoints ());
gdb/gdbserver/ * server.h (LONGEST): New. (struct thread_info) <while_stepping>: New field. (unpack_varlen_hex, xrealloc, pulongest, plongest, phex_nz): Declare. (initialize_tracepoint, handle_tracepoint_general_set) (handle_tracepoint_query, tracepoint_finished_step) (tracepoint_was_hit, release_while_stepping_state_list): (current_traceframe): Declare. * server.c (handle_general_set): Handle tracepoint packets. (read_memory): New. (write_memory): New. (handle_search_memory_1): Use read_memory. (handle_query): Report support for conditional tracepoints, trace state variables, and tracepoint sources. Handle tracepoint queries. (main): Initialize the tracepoints module. (process_serial_event): Handle traceframe reads/writes. * linux-low.c (handle_tracepoints): New. (linux_wait_1): Call it. (linux_resume_one_lwp): Handle while-stepping. (linux_supports_tracepoints, linux_read_pc, linux_write_pc): New. (linux_target_ops): Install them. * linux-low.h (struct linux_target_ops) <supports_tracepoints>: New field. * linux-x86-low.c (x86_supports_tracepoints): New. (the_low_target). Install it. * mem-break.h (delete_breakpoint): Declare. * mem-break.c (delete_breakpoint): Make external. * target.h (struct target_ops): Add `supports_tracepoints', `read_pc', and `write_pc' fields. (target_supports_tracepoints): Define. * utils.c (xrealloc, decimal2str, pulongest, plongest, thirty_two) (phex_nz): New. * regcache.h (struct regcache) <registers_owned>: New field. (init_register_cache, regcache_cpy): Declare. (regcache_read_pc, regcache_write_pc): Declare. (register_cache_size): Declare. (supply_regblock): Declare. * regcache.c (init_register_cache): New. (new_register_cache): Use it. (regcache_cpy): New. (register_cache_size): New. (supply_regblock): New. (regcache_read_pc, regcache_write_pc): New. * tracepoint.c: New. * Makefile.in (OBS): Add tracepoint.o. (tracepoint.o): New rule. gdb/ * regformats/regdat.sh: Include server.h. Don't include regcache.h.
2010-04-09 05:40:00 +02:00
gdbserver/linux-low: turn 'get_pc' and 'set_pc' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Turn the 'get_pc' and 'set_pc' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. * linux-low.cc (supports_breakpoints): Turn into... (linux_process_target::low_supports_breakpoints): ...this. (linux_process_target::low_get_pc): Define. (linux_process_target::low_set_pc): Define. Update the callers below. (linux_process_target::get_pc) (linux_process_target::save_stop_reason) (linux_process_target::maybe_move_out_of_jump_pad) (linux_process_target::wait_1) (linux_process_target::resume_one_lwp_throw) (linux_process_target::resume) (linux_process_target::proceed_all_lwps) (linux_process_target::read_pc) (linux_process_target::write_pc) * linux-x86-low.cc (class linux_process_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (x86_target::low_supports_breakpoints): Define. (x86_get_pc): Turn into... (x86_target::low_get_pc): ...this. (x86_set_pc): Turn into... (x86_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (arm_target::low_supports_breakpoints) (arm_target::low_get_pc) (arm_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (bfin_target::low_supports_breakpoints) (bfin_target::low_get_pc) (bfin_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (cris_target::low_supports_breakpoints) (cris_target::low_get_pc) (cris_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (crisv32_target::low_supports_breakpoints) (crisv32_target::low_get_pc) (crisv32_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m32r_target::low_supports_breakpoints) (m32r_target::low_get_pc) (m32r_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (m68k_target::low_supports_breakpoints) (m68k_target::low_get_pc) (m68k_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (nios2_target::low_supports_breakpoints) (nios2_target::low_get_pc) (nios2_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (sh_target::low_supports_breakpoints) (sh_target::low_get_pc) (sh_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (xtensa_target::low_supports_breakpoints) (xtensa_target::low_get_pc) (xtensa_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) <low_supports_breakpoints> <low_get_pc>: Declare. (sparc_target::low_supports_breakpoints) (sparc_target::low_get_pc): Define. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tile_target::low_supports_breakpoints) (tile_target::low_get_pc) (tile_target::low_set_pc): Define. (the_low_target): Remove the op fields. * linux-aarch64-low.cc (class aarch64_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (aarch64_target::low_supports_breakpoints): Define. (aarch64_get_pc): Turn into... (aarch64_target::low_get_pc): ...this. (aarch64_set_pc): Turn into... (aarch64_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (mips_target::low_supports_breakpoints): Define. (mips_get_pc): Turn into... (mips_target::low_get_pc): ...this. (mips_set_pc): Turn into... (mips_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (ppc_target::low_supports_breakpoints): Define. (ppc_get_pc): Turn into... (ppc_target::low_get_pc): ...this. (ppc_set_pc): Turn into... (ppc_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (riscv_target::low_supports_breakpoints): Define. (riscv_get_pc): Turn into... (riscv_target::low_get_pc): ...this. (riscv_set_pc): Turn into... (riscv_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (s390_target::low_supports_breakpoints): Define. (s390_get_pc): Turn into... (s390_target::low_get_pc): ...this. (s390_set_pc): Turn into... (s390_target::low_set_pc): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) <low_supports_breakpoints> <low_get_pc> <low_set_pc>: Declare. (tic6x_target::low_supports_breakpoints): Define. (tic6x_get_pc): Turn into... (tic6x_target::low_get_pc): ...this. (tic6x_set_pc): Turn into... (tic6x_target::low_set_pc): ...this. (the_low_target): Remove the op fields.
2020-04-02 15:11:24 +02:00
low_set_pc (regcache, pc);
gdb/gdbserver/ * server.h (LONGEST): New. (struct thread_info) <while_stepping>: New field. (unpack_varlen_hex, xrealloc, pulongest, plongest, phex_nz): Declare. (initialize_tracepoint, handle_tracepoint_general_set) (handle_tracepoint_query, tracepoint_finished_step) (tracepoint_was_hit, release_while_stepping_state_list): (current_traceframe): Declare. * server.c (handle_general_set): Handle tracepoint packets. (read_memory): New. (write_memory): New. (handle_search_memory_1): Use read_memory. (handle_query): Report support for conditional tracepoints, trace state variables, and tracepoint sources. Handle tracepoint queries. (main): Initialize the tracepoints module. (process_serial_event): Handle traceframe reads/writes. * linux-low.c (handle_tracepoints): New. (linux_wait_1): Call it. (linux_resume_one_lwp): Handle while-stepping. (linux_supports_tracepoints, linux_read_pc, linux_write_pc): New. (linux_target_ops): Install them. * linux-low.h (struct linux_target_ops) <supports_tracepoints>: New field. * linux-x86-low.c (x86_supports_tracepoints): New. (the_low_target). Install it. * mem-break.h (delete_breakpoint): Declare. * mem-break.c (delete_breakpoint): Make external. * target.h (struct target_ops): Add `supports_tracepoints', `read_pc', and `write_pc' fields. (target_supports_tracepoints): Define. * utils.c (xrealloc, decimal2str, pulongest, plongest, thirty_two) (phex_nz): New. * regcache.h (struct regcache) <registers_owned>: New field. (init_register_cache, regcache_cpy): Declare. (regcache_read_pc, regcache_write_pc): Declare. (register_cache_size): Declare. (supply_regblock): Declare. * regcache.c (init_register_cache): New. (new_register_cache): Use it. (regcache_cpy): New. (register_cache_size): New. (supply_regblock): New. (regcache_read_pc, regcache_write_pc): New. * tracepoint.c: New. * Makefile.in (OBS): Add tracepoint.o. (tracepoint.o): New rule. gdb/ * regformats/regdat.sh: Include server.h. Don't include regcache.h.
2010-04-09 05:40:00 +02:00
}
bool
linux_process_target::supports_thread_stopped ()
{
return true;
}
bool
linux_process_target::thread_stopped (thread_info *thread)
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
{
return get_thread_lwp (thread)->stopped;
}
/* This exposes stop-all-threads functionality to other modules. */
void
linux_process_target::pause_all (bool freeze)
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
{
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
stop_all_lwps (freeze, NULL);
}
/* This exposes unstop-all-threads functionality to other gdbserver
modules. */
void
linux_process_target::unpause_all (bool unfreeze)
* linux-low.c (linux_kill, linux_detach): Adjust. (status_pending_p_callback): Remove redundant statement. Check for !TARGET_WAITIKIND_IGNORE, instead of TARGET_WAITKIND_STOPPED. (handle_tracepoints): Make sure LWP is locked. Adjust. (linux_wait_for_event_1): Adjust. (linux_cancel_breakpoints): New. (unsuspend_one_lwp): New. (unsuspend_all_lwps): New. (linux_wait_1): If finishing a step-over, unsuspend all lwps. (send_sigstop_callback): Change return type to int, add new `except' parameter and handle it. (suspend_and_send_sigstop_callback): New. (stop_all_lwps): Add new `suspend' and `expect' parameters, and pass them down. If SUSPEND, also increment the lwp's suspend count. (linux_resume_one_lwp): Add notice about resuming a suspended LWP. (need_step_over_p): Don't consider suspended LWPs. (start_step_over): Adjust. (proceed_one_lwp): Change return type to int, add new `except' parameter and handle it. (unsuspend_and_proceed_one_lwp): New. (proceed_all_lwps): Use find_inferior instead of for_each_inferior. (unstop_all_lwps): Add `unsuspend' parameter. If UNSUSPEND, them also decrement the suspend count of LWPs. Pass `except' down, instead of hacking its suspend count. (linux_pause_all): Add `freeze' parameter. Adjust. (linux_unpause_all): New. (linux_target_ops): Install linux_unpause_all. * server.c (handle_status): Adjust. * target.h (struct target_ops): New fields `unpause_all' and `cancel_breakpoints'. Add new parameter to `pause_all'. (pause_all): Add new `freeze' parameter. (unpause_all): New. (cancel_breakpoints): New. * tracepoint.c (clear_installed_tracepoints): Pause threads, and cancel breakpoints. (cmd_qtstart): Pause threads. (stop_tracing): Pause threads, and cancel breakpoints. * win32-low.c (win32_target_ops): Adjust.
2010-05-03 06:02:20 +02:00
{
unstop_all_lwps (unfreeze, NULL);
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
}
int
linux_process_target::prepare_to_access_memory ()
{
/* Neither ptrace nor /proc/PID/mem allow accessing memory through a
running LWP. */
if (non_stop)
target_pause_all (true);
return 0;
}
void
linux_process_target::done_accessing_memory ()
{
/* Neither ptrace nor /proc/PID/mem allow accessing memory through a
running LWP. */
if (non_stop)
target_unpause_all (true);
}
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
/* Extract &phdr and num_phdr in the inferior. Return 0 on success. */
static int
get_phdr_phnum_from_proc_auxv (const int pid, const int is_elf64,
CORE_ADDR *phdr_memaddr, int *num_phdr)
{
char filename[PATH_MAX];
int fd;
const int auxv_size = is_elf64
? sizeof (Elf64_auxv_t) : sizeof (Elf32_auxv_t);
char buf[sizeof (Elf64_auxv_t)]; /* The larger of the two. */
xsnprintf (filename, sizeof filename, "/proc/%d/auxv", pid);
fd = open (filename, O_RDONLY);
if (fd < 0)
return 1;
*phdr_memaddr = 0;
*num_phdr = 0;
while (read (fd, buf, auxv_size) == auxv_size
&& (*phdr_memaddr == 0 || *num_phdr == 0))
{
if (is_elf64)
{
Elf64_auxv_t *const aux = (Elf64_auxv_t *) buf;
switch (aux->a_type)
{
case AT_PHDR:
*phdr_memaddr = aux->a_un.a_val;
break;
case AT_PHNUM:
*num_phdr = aux->a_un.a_val;
break;
}
}
else
{
Elf32_auxv_t *const aux = (Elf32_auxv_t *) buf;
switch (aux->a_type)
{
case AT_PHDR:
*phdr_memaddr = aux->a_un.a_val;
break;
case AT_PHNUM:
*num_phdr = aux->a_un.a_val;
break;
}
}
}
close (fd);
if (*phdr_memaddr == 0 || *num_phdr == 0)
{
warning ("Unexpected missing AT_PHDR and/or AT_PHNUM: "
"phdr_memaddr = %ld, phdr_num = %d",
(long) *phdr_memaddr, *num_phdr);
return 2;
}
return 0;
}
/* Return &_DYNAMIC (via PT_DYNAMIC) in the inferior, or 0 if not present. */
static CORE_ADDR
get_dynamic (const int pid, const int is_elf64)
{
CORE_ADDR phdr_memaddr, relocation;
Revert the previous 7 commits of: Validate binary before use ddc98fbf2fd9e244a215a4d09e559180dc573a14 Create empty nat/linux-maps.[ch] and common/target-utils.[ch] 6e5b4429db0d66e2d0b27e1bcfe4709f3dae73ed Move gdb_regex* to common/ f7af1fcd759fa126612018a5916cf808df7bb8bc Prepare linux_find_memory_regions_full & co. for move 9904185cfde13d6c6849f1f042c8e3b74974cf08 Move linux_find_memory_regions_full & co. 700ca40f6fc1addd7238f4ab57f76c095ad3c99f gdbserver build-id attribute generator ca5268b6be265580b91ef75c1a1a9815f581ae42 Validate symbol file using build-id 0a94970d663a053c523f23ac0d71deb25a77f709 Tests for validate symbol file using build-id gdb/ChangeLog 2015-07-15 Jan Kratochvil <jan.kratochvil@redhat.com> Revert the previous 6 commits: Create empty nat/linux-maps.[ch] and common/target-utils.[ch]. Move gdb_regex* to common/ Prepare linux_find_memory_regions_full & co. for move Move linux_find_memory_regions_full & co. gdbserver build-id attribute generator Validate symbol file using build-id gdb/gdbserver/ChangeLog 2015-07-15 Jan Kratochvil <jan.kratochvil@redhat.com> Revert the previous 3 commits: Move gdb_regex* to common/ Move linux_find_memory_regions_full & co. gdbserver build-id attribute generator gdb/doc/ChangeLog 2015-07-15 Jan Kratochvil <jan.kratochvil@redhat.com> Revert the previous 2 commits: gdbserver build-id attribute generator Validate symbol file using build-id gdb/testsuite/ChangeLog 2015-07-15 Jan Kratochvil <jan.kratochvil@redhat.com> Revert the previous commit: Tests for validate symbol file using build-id.
2015-07-15 20:27:32 +02:00
int num_phdr, i;
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
unsigned char *phdr_buf;
Revert the previous 7 commits of: Validate binary before use ddc98fbf2fd9e244a215a4d09e559180dc573a14 Create empty nat/linux-maps.[ch] and common/target-utils.[ch] 6e5b4429db0d66e2d0b27e1bcfe4709f3dae73ed Move gdb_regex* to common/ f7af1fcd759fa126612018a5916cf808df7bb8bc Prepare linux_find_memory_regions_full & co. for move 9904185cfde13d6c6849f1f042c8e3b74974cf08 Move linux_find_memory_regions_full & co. 700ca40f6fc1addd7238f4ab57f76c095ad3c99f gdbserver build-id attribute generator ca5268b6be265580b91ef75c1a1a9815f581ae42 Validate symbol file using build-id 0a94970d663a053c523f23ac0d71deb25a77f709 Tests for validate symbol file using build-id gdb/ChangeLog 2015-07-15 Jan Kratochvil <jan.kratochvil@redhat.com> Revert the previous 6 commits: Create empty nat/linux-maps.[ch] and common/target-utils.[ch]. Move gdb_regex* to common/ Prepare linux_find_memory_regions_full & co. for move Move linux_find_memory_regions_full & co. gdbserver build-id attribute generator Validate symbol file using build-id gdb/gdbserver/ChangeLog 2015-07-15 Jan Kratochvil <jan.kratochvil@redhat.com> Revert the previous 3 commits: Move gdb_regex* to common/ Move linux_find_memory_regions_full & co. gdbserver build-id attribute generator gdb/doc/ChangeLog 2015-07-15 Jan Kratochvil <jan.kratochvil@redhat.com> Revert the previous 2 commits: gdbserver build-id attribute generator Validate symbol file using build-id gdb/testsuite/ChangeLog 2015-07-15 Jan Kratochvil <jan.kratochvil@redhat.com> Revert the previous commit: Tests for validate symbol file using build-id.
2015-07-15 20:27:32 +02:00
const int phdr_size = is_elf64 ? sizeof (Elf64_Phdr) : sizeof (Elf32_Phdr);
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
if (get_phdr_phnum_from_proc_auxv (pid, is_elf64, &phdr_memaddr, &num_phdr))
return 0;
gdb_assert (num_phdr < 100); /* Basic sanity check. */
Add casts to memory allocation related calls Most allocation functions (if not all) return a void* pointing to the allocated memory. In C++, we need to add an explicit cast when assigning the result to a pointer to another type (which is the case more often than not). The content of this patch is taken from Pedro's branch, from commit "(mostly) auto-generated patch to insert casts needed for C++". I validated that the changes make sense and manually reflowed the code to make it respect the coding style. I also found multiple places where I could use XNEW/XNEWVEC/XRESIZEVEC/etc. Thanks a lot to whoever did that automated script to insert casts, doing it completely by hand would have taken a ridiculous amount of time. Only files built on x86 with --enable-targets=all are modified. This means that all other -nat.c files are untouched and will have to be dealt with later by using appropiate compilers. Or maybe we can try to build them with a regular g++ just to know where to add casts, I don't know. I built-tested this with --enable-targets=all and reg-tested. Here's the changelog entry, which was not too bad to make despite the size, thanks to David Malcom's script. I fixed some bits by hand, but there might be some wrong parts left (hopefully not). gdb/ChangeLog: * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Add cast to allocation result assignment. * ada-exp.y (write_object_renaming): Likewise. (write_ambiguous_var): Likewise. (ada_nget_field_index): Likewise. (write_var_or_type): Likewise. * ada-lang.c (ada_decode_symbol): Likewise. (ada_value_assign): Likewise. (value_pointer): Likewise. (cache_symbol): Likewise. (add_nonlocal_symbols): Likewise. (ada_name_for_lookup): Likewise. (symbol_completion_add): Likewise. (ada_to_fixed_type_1): Likewise. (ada_get_next_arg): Likewise. (defns_collected): Likewise. * ada-lex.l (processId): Likewise. (processString): Likewise. * ada-tasks.c (read_known_tasks_array): Likewise. (read_known_tasks_list): Likewise. * ada-typeprint.c (decoded_type_name): Likewise. * addrmap.c (addrmap_mutable_create_fixed): Likewise. * amd64-tdep.c (amd64_push_arguments): Likewise. (amd64_displaced_step_copy_insn): Likewise. (amd64_classify_insn_at): Likewise. (amd64_relocate_instruction): Likewise. * amd64obsd-tdep.c (amd64obsd_sigtramp_p): Likewise. * arch-utils.c (simple_displaced_step_copy_insn): Likewise. (initialize_current_architecture): Likewise. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * arm-symbian-tdep.c (arm_symbian_osabi_sniffer): Likewise. * arm-tdep.c (arm_exidx_new_objfile): Likewise. (arm_push_dummy_call): Likewise. (extend_buffer_earlier): Likewise. (arm_adjust_breakpoint_address): Likewise. (arm_skip_stub): Likewise. * auto-load.c (filename_is_in_pattern): Likewise. (maybe_add_script_file): Likewise. (maybe_add_script_text): Likewise. (auto_load_objfile_script_1): Likewise. * auxv.c (ld_so_xfer_auxv): Likewise. * ax-general.c (new_agent_expr): Likewise. (grow_expr): Likewise. (ax_reg_mask): Likewise. * bcache.c (bcache_full): Likewise. * breakpoint.c (program_breakpoint_here_p): Likewise. * btrace.c (parse_xml_raw): Likewise. * build-id.c (build_id_to_debug_bfd): Likewise. * buildsym.c (end_symtab_with_blockvector): Likewise. * c-exp.y (string_exp): Likewise. (qualified_name): Likewise. (write_destructor_name): Likewise. (operator_stoken): Likewise. (parse_number): Likewise. (scan_macro_expansion): Likewise. (yylex): Likewise. (c_print_token): Likewise. * c-lang.c (c_get_string): Likewise. (emit_numeric_character): Likewise. * charset.c (wchar_iterate): Likewise. * cli/cli-cmds.c (complete_command): Likewise. (make_command): Likewise. * cli/cli-dump.c (restore_section_callback): Likewise. (restore_binary_file): Likewise. * cli/cli-interp.c (cli_interpreter_exec): Likewise. * cli/cli-script.c (execute_control_command): Likewise. * cli/cli-setshow.c (do_set_command): Likewise. * coff-pe-read.c (add_pe_forwarded_sym): Likewise. (read_pe_exported_syms): Likewise. * coffread.c (coff_read_struct_type): Likewise. (coff_read_enum_type): Likewise. * common/btrace-common.c (btrace_data_append): Likewise. * common/buffer.c (buffer_grow): Likewise. * common/filestuff.c (gdb_fopen_cloexec): Likewise. * common/format.c (parse_format_string): Likewise. * common/gdb_vecs.c (delim_string_to_char_ptr_vec_append): Likewise. * common/xml-utils.c (xml_escape_text): Likewise. * compile/compile-object-load.c (copy_sections): Likewise. (compile_object_load): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * completer.c (filename_completer): Likewise. * corefile.c (read_memory_typed_address): Likewise. (write_memory_unsigned_integer): Likewise. (write_memory_signed_integer): Likewise. (complete_set_gnutarget): Likewise. * corelow.c (get_core_register_section): Likewise. * cp-name-parser.y (d_grab): Likewise. (allocate_info): Likewise. (cp_new_demangle_parse_info): Likewise. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Likewise. (cp_lookup_symbol_in_namespace): Likewise. (lookup_namespace_scope): Likewise. (find_symbol_in_baseclass): Likewise. (cp_lookup_nested_symbol): Likewise. (cp_lookup_transparent_type_loop): Likewise. * cp-support.c (copy_string_to_obstack): Likewise. (make_symbol_overload_list): Likewise. (make_symbol_overload_list_namespace): Likewise. (make_symbol_overload_list_adl_namespace): Likewise. (first_component_command): Likewise. * cp-valprint.c (cp_print_value): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * d-exp.y (StringExp): Likewise. * d-namespace.c (d_lookup_symbol_in_module): Likewise. (lookup_module_scope): Likewise. (find_symbol_in_baseclass): Likewise. (d_lookup_nested_symbol): Likewise. * dbxread.c (find_stab_function_addr): Likewise. (read_dbx_symtab): Likewise. (dbx_end_psymtab): Likewise. (cp_set_block_scope): Likewise. * dcache.c (dcache_alloc): Likewise. * demangle.c (_initialize_demangler): Likewise. * dicos-tdep.c (dicos_load_module_p): Likewise. * dictionary.c (dict_create_hashed_expandable): Likewise. (dict_create_linear_expandable): Likewise. (expand_hashtable): Likewise. (add_symbol_linear_expandable): Likewise. * dwarf2-frame.c (add_cie): Likewise. (add_fde): Likewise. (dwarf2_build_frame_info): Likewise. * dwarf2expr.c (dwarf_expr_grow_stack): Likewise. (dwarf_expr_fetch_address): Likewise. (add_piece): Likewise. (execute_stack_op): Likewise. * dwarf2loc.c (chain_candidate): Likewise. (dwarf_entry_parameter_to_value): Likewise. (read_pieced_value): Likewise. (write_pieced_value): Likewise. * dwarf2read.c (dwarf2_read_section): Likewise. (add_type_unit): Likewise. (read_comp_units_from_section): Likewise. (fixup_go_packaging): Likewise. (dwarf2_compute_name): Likewise. (dwarf2_physname): Likewise. (create_dwo_unit_in_dwp_v1): Likewise. (create_dwo_unit_in_dwp_v2): Likewise. (read_func_scope): Likewise. (read_call_site_scope): Likewise. (dwarf2_attach_fields_to_type): Likewise. (process_structure_scope): Likewise. (mark_common_block_symbol_computed): Likewise. (read_common_block): Likewise. (abbrev_table_read_table): Likewise. (guess_partial_die_structure_name): Likewise. (fixup_partial_die): Likewise. (add_file_name): Likewise. (dwarf2_const_value_data): Likewise. (dwarf2_const_value_attr): Likewise. (build_error_marker_type): Likewise. (guess_full_die_structure_name): Likewise. (anonymous_struct_prefix): Likewise. (typename_concat): Likewise. (dwarf2_canonicalize_name): Likewise. (dwarf2_name): Likewise. (write_constant_as_bytes): Likewise. (dwarf2_fetch_constant_bytes): Likewise. (copy_string): Likewise. (parse_macro_definition): Likewise. * elfread.c (elf_symfile_segments): Likewise. (elf_rel_plt_read): Likewise. (elf_gnu_ifunc_resolve_by_cache): Likewise. (elf_gnu_ifunc_resolve_by_got): Likewise. (elf_read_minimal_symbols): Likewise. (elf_gnu_ifunc_record_cache): Likewise. * event-top.c (top_level_prompt): Likewise. (command_line_handler): Likewise. * exec.c (resize_section_table): Likewise. * expprint.c (print_subexp_standard): Likewise. * fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise. * findcmd.c (parse_find_args): Likewise. * findvar.c (address_from_register): Likewise. * frame.c (get_prev_frame_always): Likewise. * gdb_bfd.c (gdb_bfd_ref): Likewise. (get_section_descriptor): Likewise. * gdb_obstack.c (obconcat): Likewise. (obstack_strdup): Likewise. * gdbtypes.c (lookup_function_type_with_arguments): Likewise. (create_set_type): Likewise. (lookup_unsigned_typename): Likewise. (lookup_signed_typename): Likewise. (resolve_dynamic_union): Likewise. (resolve_dynamic_struct): Likewise. (add_dyn_prop): Likewise. (copy_dynamic_prop_list): Likewise. (arch_flags_type): Likewise. (append_composite_type_field_raw): Likewise. * gdbtypes.h (INIT_FUNC_SPECIFIC): Likewise. * gnu-v3-abi.c (gnuv3_rtti_type): Likewise. * go-exp.y (string_exp): Likewise. * go-lang.c (go_demangle): Likewise. * guile/guile.c (compute_scheme_string): Likewise. * guile/scm-cmd.c (gdbscm_parse_command_name): Likewise. (gdbscm_canonicalize_command_name): Likewise. * guile/scm-ports.c (ioscm_init_stdio_buffers): Likewise. (ioscm_init_memory_port): Likewise. (ioscm_reinit_memory_port): Likewise. * guile/scm-utils.c (gdbscm_gc_xstrdup): Likewise. (gdbscm_gc_dup_argv): Likewise. * h8300-tdep.c (h8300_push_dummy_call): Likewise. * hppa-tdep.c (internalize_unwinds): Likewise. (read_unwind_info): Likewise. * i386-cygwin-tdep.c (core_process_module_section): Likewise. (windows_core_xfer_shared_libraries): Likewise. * i386-tdep.c (i386_displaced_step_copy_insn): Likewise. (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * i386obsd-tdep.c (i386obsd_sigtramp_p): Likewise. * inf-child.c (inf_child_fileio_readlink): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_store_register): Likewise. * infrun.c (follow_exec): Likewise. (displaced_step_prepare_throw): Likewise. (save_stop_context): Likewise. (save_infcall_suspend_state): Likewise. * jit.c (jit_read_descriptor): Likewise. (jit_read_code_entry): Likewise. (jit_symtab_line_mapping_add_impl): Likewise. (finalize_symtab): Likewise. (jit_unwind_reg_get_impl): Likewise. * jv-exp.y (QualifiedName): Likewise. * jv-lang.c (get_java_utf8_name): Likewise. (type_from_class): Likewise. (java_demangle_type_signature): Likewise. (java_class_name_from_physname): Likewise. * jv-typeprint.c (java_type_print_base): Likewise. * jv-valprint.c (java_value_print): Likewise. * language.c (add_language): Likewise. * linespec.c (add_sal_to_sals_basic): Likewise. (add_sal_to_sals): Likewise. (decode_objc): Likewise. (find_linespec_symbols): Likewise. * linux-fork.c (fork_save_infrun_state): Likewise. * linux-nat.c (linux_nat_detach): Likewise. (linux_nat_fileio_readlink): Likewise. * linux-record.c (record_linux_sockaddr): Likewise. (record_linux_msghdr): Likewise. (Do): Likewise. * linux-tdep.c (linux_core_info_proc_mappings): Likewise. (linux_collect_regset_section_cb): Likewise. (linux_get_siginfo_data): Likewise. * linux-thread-db.c (try_thread_db_load_from_pdir_1): Likewise. (try_thread_db_load_from_dir): Likewise. (thread_db_load_search): Likewise. (info_auto_load_libthread_db): Likewise. * m32c-tdep.c (m32c_m16c_address_to_pointer): Likewise. (m32c_m16c_pointer_to_address): Likewise. * m68hc11-tdep.c (m68hc11_pseudo_register_write): Likewise. * m68k-tdep.c (m68k_get_longjmp_target): Likewise. * machoread.c (macho_check_dsym): Likewise. * macroexp.c (resize_buffer): Likewise. (gather_arguments): Likewise. (maybe_expand): Likewise. * macrotab.c (new_macro_key): Likewise. (new_source_file): Likewise. (new_macro_definition): Likewise. * mdebugread.c (parse_symbol): Likewise. (parse_type): Likewise. (parse_partial_symbols): Likewise. (psymtab_to_symtab_1): Likewise. * mem-break.c (default_memory_insert_breakpoint): Likewise. * mi/mi-cmd-break.c (mi_argv_to_format): Likewise. * mi/mi-main.c (mi_cmd_data_read_memory): Likewise. (mi_cmd_data_read_memory_bytes): Likewise. (mi_cmd_data_write_memory_bytes): Likewise. (mi_cmd_trace_frame_collected): Likewise. * mi/mi-parse.c (mi_parse_argv): Likewise. (mi_parse): Likewise. * minidebug.c (lzma_open): Likewise. (lzma_pread): Likewise. * mips-tdep.c (mips_read_fp_register_single): Likewise. (mips_print_fp_register): Likewise. * mipsnbsd-tdep.c (mipsnbsd_get_longjmp_target): Likewise. * mipsread.c (read_alphacoff_dynamic_symtab): Likewise. * mt-tdep.c (mt_register_name): Likewise. (mt_registers_info): Likewise. (mt_push_dummy_call): Likewise. * namespace.c (add_using_directive): Likewise. * nat/linux-btrace.c (perf_event_read): Likewise. (linux_enable_bts): Likewise. * nat/linux-osdata.c (linux_common_core_of_thread): Likewise. * nat/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Likewise. * nto-tdep.c (nto_find_and_open_solib): Likewise. (nto_parse_redirection): Likewise. * objc-lang.c (objc_demangle): Likewise. (find_methods): Likewise. * objfiles.c (get_objfile_bfd_data): Likewise. (set_objfile_main_name): Likewise. (allocate_objfile): Likewise. (objfile_relocate): Likewise. (update_section_map): Likewise. * osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Likewise. * p-exp.y (exp): Likewise. (yylex): Likewise. * p-valprint.c (pascal_object_print_value): Likewise. * parse.c (initialize_expout): Likewise. (mark_completion_tag): Likewise. (copy_name): Likewise. (parse_float): Likewise. (type_stack_reserve): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. (ppu2spu_prev_register): Likewise. * ppc-ravenscar-thread.c (supply_register_at_address): Likewise. * printcmd.c (printf_wide_c_string): Likewise. (printf_pointer): Likewise. * probe.c (parse_probes): Likewise. * python/py-cmd.c (gdbpy_parse_command_name): Likewise. (cmdpy_init): Likewise. * python/py-gdb-readline.c (gdbpy_readline_wrapper): Likewise. * python/py-symtab.c (set_sal): Likewise. * python/py-unwind.c (pyuw_sniffer): Likewise. * python/python.c (python_interactive_command): Likewise. (compute_python_string): Likewise. * ravenscar-thread.c (get_running_thread_id): Likewise. * record-full.c (record_full_exec_insn): Likewise. (record_full_core_open_1): Likewise. * regcache.c (regcache_raw_read_signed): Likewise. (regcache_raw_read_unsigned): Likewise. (regcache_cooked_read_signed): Likewise. (regcache_cooked_read_unsigned): Likewise. * remote-fileio.c (remote_fileio_func_open): Likewise. (remote_fileio_func_rename): Likewise. (remote_fileio_func_unlink): Likewise. (remote_fileio_func_stat): Likewise. (remote_fileio_func_system): Likewise. * remote-mips.c (mips_xfer_memory): Likewise. (mips_load_srec): Likewise. (pmon_end_download): Likewise. * remote.c (new_remote_state): Likewise. (map_regcache_remote_table): Likewise. (remote_register_number_and_offset): Likewise. (init_remote_state): Likewise. (get_memory_packet_size): Likewise. (remote_pass_signals): Likewise. (remote_program_signals): Likewise. (remote_start_remote): Likewise. (remote_check_symbols): Likewise. (remote_query_supported): Likewise. (extended_remote_attach): Likewise. (process_g_packet): Likewise. (store_registers_using_G): Likewise. (putpkt_binary): Likewise. (read_frame): Likewise. (compare_sections_command): Likewise. (remote_hostio_pread): Likewise. (remote_hostio_readlink): Likewise. (remote_file_put): Likewise. (remote_file_get): Likewise. (remote_pid_to_exec_file): Likewise. (_initialize_remote): Likewise. * rs6000-aix-tdep.c (rs6000_aix_ld_info_to_xml): Likewise. (rs6000_aix_core_xfer_shared_libraries_aix): Likewise. * rs6000-tdep.c (ppc_displaced_step_copy_insn): Likewise. (bfd_uses_spe_extensions): Likewise. * s390-linux-tdep.c (s390_displaced_step_copy_insn): Likewise. * score-tdep.c (score7_malloc_and_get_memblock): Likewise. * solib-dsbt.c (decode_loadmap): Likewise. (fetch_loadmap): Likewise. (scan_dyntag): Likewise. (enable_break): Likewise. (dsbt_relocate_main_executable): Likewise. * solib-frv.c (fetch_loadmap): Likewise. (enable_break2): Likewise. (frv_relocate_main_executable): Likewise. * solib-spu.c (spu_relocate_main_executable): Likewise. (spu_bfd_open): Likewise. * solib-svr4.c (lm_info_read): Likewise. (read_program_header): Likewise. (find_program_interpreter): Likewise. (scan_dyntag): Likewise. (elf_locate_base): Likewise. (open_symbol_file_object): Likewise. (read_program_headers_from_bfd): Likewise. (svr4_relocate_main_executable): Likewise. * solib-target.c (solib_target_relocate_section_addresses): Likewise. * solib.c (solib_find_1): Likewise. (exec_file_find): Likewise. (solib_find): Likewise. * source.c (openp): Likewise. (print_source_lines_base): Likewise. (forward_search_command): Likewise. * sparc-ravenscar-thread.c (supply_register_at_address): Likewise. * spu-tdep.c (spu2ppu_prev_register): Likewise. (spu_get_overlay_table): Likewise. * stabsread.c (patch_block_stabs): Likewise. (define_symbol): Likewise. (again:): Likewise. (read_member_functions): Likewise. (read_one_struct_field): Likewise. (read_enum_type): Likewise. (common_block_start): Likewise. * stack.c (read_frame_arg): Likewise. (backtrace_command): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. * symfile.c (syms_from_objfile_1): Likewise. (find_separate_debug_file): Likewise. (load_command): Likewise. (load_progress): Likewise. (load_section_callback): Likewise. (reread_symbols): Likewise. (add_filename_language): Likewise. (allocate_compunit_symtab): Likewise. (read_target_long_array): Likewise. (simple_read_overlay_table): Likewise. * symtab.c (symbol_set_names): Likewise. (resize_symbol_cache): Likewise. (rbreak_command): Likewise. (completion_list_add_name): Likewise. (completion_list_objc_symbol): Likewise. (add_filename_to_list): Likewise. * target-descriptions.c (maint_print_c_tdesc_cmd): Likewise. * target-memory.c (target_write_memory_blocks): Likewise. * target.c (target_read_string): Likewise. (read_whatever_is_readable): Likewise. (target_read_alloc_1): Likewise. (simple_search_memory): Likewise. (target_fileio_read_alloc_1): Likewise. * tilegx-tdep.c (tilegx_push_dummy_call): Likewise. * top.c (command_line_input): Likewise. * tracefile-tfile.c (tfile_fetch_registers): Likewise. * tracefile.c (tracefile_fetch_registers): Likewise. * tracepoint.c (add_memrange): Likewise. (init_collection_list): Likewise. (add_aexpr): Likewise. (trace_dump_actions): Likewise. (parse_trace_status): Likewise. (parse_tracepoint_definition): Likewise. (parse_tsv_definition): Likewise. (parse_static_tracepoint_marker_definition): Likewise. * tui/tui-file.c (tui_sfileopen): Likewise. (tui_file_adjust_strbuf): Likewise. * tui/tui-io.c (tui_expand_tabs): Likewise. * tui/tui-source.c (tui_set_source_content): Likewise. * typeprint.c (find_global_typedef): Likewise. * ui-file.c (do_ui_file_xstrdup): Likewise. (ui_file_obsavestring): Likewise. (mem_file_write): Likewise. * utils.c (make_hex_string): Likewise. (get_regcomp_error): Likewise. (puts_filtered_tabular): Likewise. (gdb_realpath_keepfile): Likewise. (ldirname): Likewise. (gdb_bfd_errmsg): Likewise. (substitute_path_component): Likewise. * valops.c (search_struct_method): Likewise. (find_oload_champ_namespace_loop): Likewise. * valprint.c (print_decimal_chars): Likewise. (read_string): Likewise. (generic_emit_char): Likewise. * varobj.c (varobj_delete): Likewise. (varobj_value_get_print_value): Likewise. * vaxobsd-tdep.c (vaxobsd_sigtramp_sniffer): Likewise. * windows-tdep.c (display_one_tib): Likewise. * xcoffread.c (read_xcoff_symtab): Likewise. (process_xcoff_symbol): Likewise. (swap_sym): Likewise. (scan_xcoff_symtab): Likewise. (xcoff_initial_scan): Likewise. * xml-support.c (gdb_xml_end_element): Likewise. (xml_process_xincludes): Likewise. (xml_fetch_content_from_file): Likewise. * xml-syscall.c (xml_list_of_syscalls): Likewise. * xstormy16-tdep.c (xstormy16_push_dummy_call): Likewise. gdb/gdbserver/ChangeLog: * ax.c (gdb_parse_agent_expr): Add cast to allocation result assignment. (gdb_unparse_agent_expr): Likewise. * hostio.c (require_data): Likewise. (handle_pread): Likewise. * linux-low.c (disable_regset): Likewise. (fetch_register): Likewise. (store_register): Likewise. (get_dynamic): Likewise. (linux_qxfer_libraries_svr4): Likewise. * mem-break.c (delete_fast_tracepoint_jump): Likewise. (set_fast_tracepoint_jump): Likewise. (uninsert_fast_tracepoint_jumps_at): Likewise. (reinsert_fast_tracepoint_jumps_at): Likewise. (validate_inserted_breakpoint): Likewise. (clone_agent_expr): Likewise. * regcache.c (init_register_cache): Likewise. * remote-utils.c (putpkt_binary_1): Likewise. (decode_M_packet): Likewise. (decode_X_packet): Likewise. (look_up_one_symbol): Likewise. (relocate_instruction): Likewise. (monitor_output): Likewise. * server.c (handle_search_memory): Likewise. (handle_qxfer_exec_file): Likewise. (handle_qxfer_libraries): Likewise. (handle_qxfer): Likewise. (handle_query): Likewise. (handle_v_cont): Likewise. (handle_v_run): Likewise. (captured_main): Likewise. * target.c (write_inferior_memory): Likewise. * thread-db.c (try_thread_db_load_from_dir): Likewise. * tracepoint.c (init_trace_buffer): Likewise. (add_tracepoint_action): Likewise. (add_traceframe): Likewise. (add_traceframe_block): Likewise. (cmd_qtdpsrc): Likewise. (cmd_qtdv): Likewise. (cmd_qtstatus): Likewise. (response_source): Likewise. (response_tsv): Likewise. (cmd_qtnotes): Likewise. (gdb_collect): Likewise. (initialize_tracepoint): Likewise.
2015-09-25 20:08:06 +02:00
phdr_buf = (unsigned char *) alloca (num_phdr * phdr_size);
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
if (linux_read_memory (phdr_memaddr, phdr_buf, num_phdr * phdr_size))
return 0;
/* Compute relocation: it is expected to be 0 for "regular" executables,
non-zero for PIE ones. */
relocation = -1;
Revert the previous 7 commits of: Validate binary before use ddc98fbf2fd9e244a215a4d09e559180dc573a14 Create empty nat/linux-maps.[ch] and common/target-utils.[ch] 6e5b4429db0d66e2d0b27e1bcfe4709f3dae73ed Move gdb_regex* to common/ f7af1fcd759fa126612018a5916cf808df7bb8bc Prepare linux_find_memory_regions_full & co. for move 9904185cfde13d6c6849f1f042c8e3b74974cf08 Move linux_find_memory_regions_full & co. 700ca40f6fc1addd7238f4ab57f76c095ad3c99f gdbserver build-id attribute generator ca5268b6be265580b91ef75c1a1a9815f581ae42 Validate symbol file using build-id 0a94970d663a053c523f23ac0d71deb25a77f709 Tests for validate symbol file using build-id gdb/ChangeLog 2015-07-15 Jan Kratochvil <jan.kratochvil@redhat.com> Revert the previous 6 commits: Create empty nat/linux-maps.[ch] and common/target-utils.[ch]. Move gdb_regex* to common/ Prepare linux_find_memory_regions_full & co. for move Move linux_find_memory_regions_full & co. gdbserver build-id attribute generator Validate symbol file using build-id gdb/gdbserver/ChangeLog 2015-07-15 Jan Kratochvil <jan.kratochvil@redhat.com> Revert the previous 3 commits: Move gdb_regex* to common/ Move linux_find_memory_regions_full & co. gdbserver build-id attribute generator gdb/doc/ChangeLog 2015-07-15 Jan Kratochvil <jan.kratochvil@redhat.com> Revert the previous 2 commits: gdbserver build-id attribute generator Validate symbol file using build-id gdb/testsuite/ChangeLog 2015-07-15 Jan Kratochvil <jan.kratochvil@redhat.com> Revert the previous commit: Tests for validate symbol file using build-id.
2015-07-15 20:27:32 +02:00
for (i = 0; relocation == -1 && i < num_phdr; i++)
if (is_elf64)
{
Elf64_Phdr *const p = (Elf64_Phdr *) (phdr_buf + i * phdr_size);
if (p->p_type == PT_PHDR)
relocation = phdr_memaddr - p->p_vaddr;
}
else
{
Elf32_Phdr *const p = (Elf32_Phdr *) (phdr_buf + i * phdr_size);
if (p->p_type == PT_PHDR)
relocation = phdr_memaddr - p->p_vaddr;
}
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
if (relocation == -1)
{
/* PT_PHDR is optional, but necessary for PIE in general. Fortunately
any real world executables, including PIE executables, have always
PT_PHDR present. PT_PHDR is not present in some shared libraries or
in fpc (Free Pascal 2.4) binaries but neither of those have a need for
or present DT_DEBUG anyway (fpc binaries are statically linked).
Therefore if there exists DT_DEBUG there is always also PT_PHDR.
GDB could find RELOCATION also from AT_ENTRY - e_entry. */
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
return 0;
}
Revert the previous 7 commits of: Validate binary before use ddc98fbf2fd9e244a215a4d09e559180dc573a14 Create empty nat/linux-maps.[ch] and common/target-utils.[ch] 6e5b4429db0d66e2d0b27e1bcfe4709f3dae73ed Move gdb_regex* to common/ f7af1fcd759fa126612018a5916cf808df7bb8bc Prepare linux_find_memory_regions_full & co. for move 9904185cfde13d6c6849f1f042c8e3b74974cf08 Move linux_find_memory_regions_full & co. 700ca40f6fc1addd7238f4ab57f76c095ad3c99f gdbserver build-id attribute generator ca5268b6be265580b91ef75c1a1a9815f581ae42 Validate symbol file using build-id 0a94970d663a053c523f23ac0d71deb25a77f709 Tests for validate symbol file using build-id gdb/ChangeLog 2015-07-15 Jan Kratochvil <jan.kratochvil@redhat.com> Revert the previous 6 commits: Create empty nat/linux-maps.[ch] and common/target-utils.[ch]. Move gdb_regex* to common/ Prepare linux_find_memory_regions_full & co. for move Move linux_find_memory_regions_full & co. gdbserver build-id attribute generator Validate symbol file using build-id gdb/gdbserver/ChangeLog 2015-07-15 Jan Kratochvil <jan.kratochvil@redhat.com> Revert the previous 3 commits: Move gdb_regex* to common/ Move linux_find_memory_regions_full & co. gdbserver build-id attribute generator gdb/doc/ChangeLog 2015-07-15 Jan Kratochvil <jan.kratochvil@redhat.com> Revert the previous 2 commits: gdbserver build-id attribute generator Validate symbol file using build-id gdb/testsuite/ChangeLog 2015-07-15 Jan Kratochvil <jan.kratochvil@redhat.com> Revert the previous commit: Tests for validate symbol file using build-id.
2015-07-15 20:27:32 +02:00
for (i = 0; i < num_phdr; i++)
{
if (is_elf64)
{
Elf64_Phdr *const p = (Elf64_Phdr *) (phdr_buf + i * phdr_size);
if (p->p_type == PT_DYNAMIC)
return p->p_vaddr + relocation;
}
else
{
Elf32_Phdr *const p = (Elf32_Phdr *) (phdr_buf + i * phdr_size);
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
Revert the previous 7 commits of: Validate binary before use ddc98fbf2fd9e244a215a4d09e559180dc573a14 Create empty nat/linux-maps.[ch] and common/target-utils.[ch] 6e5b4429db0d66e2d0b27e1bcfe4709f3dae73ed Move gdb_regex* to common/ f7af1fcd759fa126612018a5916cf808df7bb8bc Prepare linux_find_memory_regions_full & co. for move 9904185cfde13d6c6849f1f042c8e3b74974cf08 Move linux_find_memory_regions_full & co. 700ca40f6fc1addd7238f4ab57f76c095ad3c99f gdbserver build-id attribute generator ca5268b6be265580b91ef75c1a1a9815f581ae42 Validate symbol file using build-id 0a94970d663a053c523f23ac0d71deb25a77f709 Tests for validate symbol file using build-id gdb/ChangeLog 2015-07-15 Jan Kratochvil <jan.kratochvil@redhat.com> Revert the previous 6 commits: Create empty nat/linux-maps.[ch] and common/target-utils.[ch]. Move gdb_regex* to common/ Prepare linux_find_memory_regions_full & co. for move Move linux_find_memory_regions_full & co. gdbserver build-id attribute generator Validate symbol file using build-id gdb/gdbserver/ChangeLog 2015-07-15 Jan Kratochvil <jan.kratochvil@redhat.com> Revert the previous 3 commits: Move gdb_regex* to common/ Move linux_find_memory_regions_full & co. gdbserver build-id attribute generator gdb/doc/ChangeLog 2015-07-15 Jan Kratochvil <jan.kratochvil@redhat.com> Revert the previous 2 commits: gdbserver build-id attribute generator Validate symbol file using build-id gdb/testsuite/ChangeLog 2015-07-15 Jan Kratochvil <jan.kratochvil@redhat.com> Revert the previous commit: Tests for validate symbol file using build-id.
2015-07-15 20:27:32 +02:00
if (p->p_type == PT_DYNAMIC)
return p->p_vaddr + relocation;
}
}
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
return 0;
}
/* Return &_r_debug in the inferior, or -1 if not present. Return value
can be 0 if the inferior does not yet have the library list initialized.
We look for DT_MIPS_RLD_MAP first. MIPS executables use this instead of
DT_DEBUG, although they sometimes contain an unused DT_DEBUG entry too. */
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
static CORE_ADDR
get_r_debug (const int pid, const int is_elf64)
{
CORE_ADDR dynamic_memaddr;
const int dyn_size = is_elf64 ? sizeof (Elf64_Dyn) : sizeof (Elf32_Dyn);
unsigned char buf[sizeof (Elf64_Dyn)]; /* The larger of the two. */
CORE_ADDR map = -1;
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
dynamic_memaddr = get_dynamic (pid, is_elf64);
if (dynamic_memaddr == 0)
return map;
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
while (linux_read_memory (dynamic_memaddr, buf, dyn_size) == 0)
{
if (is_elf64)
{
Elf64_Dyn *const dyn = (Elf64_Dyn *) buf;
#if defined DT_MIPS_RLD_MAP || defined DT_MIPS_RLD_MAP_REL
union
{
Elf64_Xword map;
unsigned char buf[sizeof (Elf64_Xword)];
}
rld_map;
#endif
#ifdef DT_MIPS_RLD_MAP
if (dyn->d_tag == DT_MIPS_RLD_MAP)
{
if (linux_read_memory (dyn->d_un.d_val,
rld_map.buf, sizeof (rld_map.buf)) == 0)
return rld_map.map;
else
break;
}
#endif /* DT_MIPS_RLD_MAP */
#ifdef DT_MIPS_RLD_MAP_REL
if (dyn->d_tag == DT_MIPS_RLD_MAP_REL)
{
if (linux_read_memory (dyn->d_un.d_val + dynamic_memaddr,
rld_map.buf, sizeof (rld_map.buf)) == 0)
return rld_map.map;
else
break;
}
#endif /* DT_MIPS_RLD_MAP_REL */
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
if (dyn->d_tag == DT_DEBUG && map == -1)
map = dyn->d_un.d_val;
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
if (dyn->d_tag == DT_NULL)
break;
}
else
{
Elf32_Dyn *const dyn = (Elf32_Dyn *) buf;
#if defined DT_MIPS_RLD_MAP || defined DT_MIPS_RLD_MAP_REL
union
{
Elf32_Word map;
unsigned char buf[sizeof (Elf32_Word)];
}
rld_map;
#endif
#ifdef DT_MIPS_RLD_MAP
if (dyn->d_tag == DT_MIPS_RLD_MAP)
{
if (linux_read_memory (dyn->d_un.d_val,
rld_map.buf, sizeof (rld_map.buf)) == 0)
return rld_map.map;
else
break;
}
#endif /* DT_MIPS_RLD_MAP */
#ifdef DT_MIPS_RLD_MAP_REL
if (dyn->d_tag == DT_MIPS_RLD_MAP_REL)
{
if (linux_read_memory (dyn->d_un.d_val + dynamic_memaddr,
rld_map.buf, sizeof (rld_map.buf)) == 0)
return rld_map.map;
else
break;
}
#endif /* DT_MIPS_RLD_MAP_REL */
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
if (dyn->d_tag == DT_DEBUG && map == -1)
map = dyn->d_un.d_val;
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
if (dyn->d_tag == DT_NULL)
break;
}
dynamic_memaddr += dyn_size;
}
return map;
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
}
/* Read one pointer from MEMADDR in the inferior. */
static int
read_one_ptr (CORE_ADDR memaddr, CORE_ADDR *ptr, int ptr_size)
{
int ret;
/* Go through a union so this works on either big or little endian
hosts, when the inferior's pointer size is smaller than the size
of CORE_ADDR. It is assumed the inferior's endianness is the
same of the superior's. */
union
{
CORE_ADDR core_addr;
unsigned int ui;
unsigned char uc;
} addr;
ret = linux_read_memory (memaddr, &addr.uc, ptr_size);
if (ret == 0)
{
if (ptr_size == sizeof (CORE_ADDR))
*ptr = addr.core_addr;
else if (ptr_size == sizeof (unsigned int))
*ptr = addr.ui;
else
gdb_assert_not_reached ("unhandled pointer size");
}
return ret;
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
}
bool
linux_process_target::supports_qxfer_libraries_svr4 ()
{
return true;
}
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
struct link_map_offsets
{
/* Offset and size of r_debug.r_version. */
int r_version_offset;
/* Offset and size of r_debug.r_map. */
int r_map_offset;
/* Offset to l_addr field in struct link_map. */
int l_addr_offset;
/* Offset to l_name field in struct link_map. */
int l_name_offset;
/* Offset to l_ld field in struct link_map. */
int l_ld_offset;
/* Offset to l_next field in struct link_map. */
int l_next_offset;
/* Offset to l_prev field in struct link_map. */
int l_prev_offset;
};
/* Construct qXfer:libraries-svr4:read reply. */
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
int
linux_process_target::qxfer_libraries_svr4 (const char *annex,
unsigned char *readbuf,
unsigned const char *writebuf,
CORE_ADDR offset, int len)
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
{
struct process_info_private *const priv = current_process ()->priv;
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
char filename[PATH_MAX];
int pid, is_elf64;
static const struct link_map_offsets lmo_32bit_offsets =
{
0, /* r_version offset. */
4, /* r_debug.r_map offset. */
0, /* l_addr offset in link_map. */
4, /* l_name offset in link_map. */
8, /* l_ld offset in link_map. */
12, /* l_next offset in link_map. */
16 /* l_prev offset in link_map. */
};
static const struct link_map_offsets lmo_64bit_offsets =
{
0, /* r_version offset. */
8, /* r_debug.r_map offset. */
0, /* l_addr offset in link_map. */
8, /* l_name offset in link_map. */
16, /* l_ld offset in link_map. */
24, /* l_next offset in link_map. */
32 /* l_prev offset in link_map. */
};
const struct link_map_offsets *lmo;
unsigned int machine;
int ptr_size;
CORE_ADDR lm_addr = 0, lm_prev = 0;
CORE_ADDR l_name, l_addr, l_ld, l_next, l_prev;
int header_done = 0;
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
if (writebuf != NULL)
return -2;
if (readbuf == NULL)
return -1;
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
pid = lwpid_of (current_thread);
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
xsnprintf (filename, sizeof filename, "/proc/%d/exe", pid);
is_elf64 = elf_64_file_p (filename, &machine);
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
lmo = is_elf64 ? &lmo_64bit_offsets : &lmo_32bit_offsets;
ptr_size = is_elf64 ? 8 : 4;
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
while (annex[0] != '\0')
{
const char *sep;
CORE_ADDR *addrp;
int name_len;
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
sep = strchr (annex, '=');
if (sep == NULL)
break;
name_len = sep - annex;
if (name_len == 5 && startswith (annex, "start"))
addrp = &lm_addr;
else if (name_len == 4 && startswith (annex, "prev"))
addrp = &lm_prev;
else
{
annex = strchr (sep, ';');
if (annex == NULL)
break;
annex++;
continue;
}
annex = decode_address_to_semicolon (addrp, sep + 1);
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
}
if (lm_addr == 0)
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
{
int r_version = 0;
if (priv->r_debug == 0)
priv->r_debug = get_r_debug (pid, is_elf64);
/* We failed to find DT_DEBUG. Such situation will not change
for this inferior - do not retry it. Report it to GDB as
E01, see for the reasons at the GDB solib-svr4.c side. */
if (priv->r_debug == (CORE_ADDR) -1)
return -1;
if (priv->r_debug != 0)
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
{
if (linux_read_memory (priv->r_debug + lmo->r_version_offset,
(unsigned char *) &r_version,
sizeof (r_version)) != 0
|| r_version != 1)
{
warning ("unexpected r_debug version %d", r_version);
}
else if (read_one_ptr (priv->r_debug + lmo->r_map_offset,
&lm_addr, ptr_size) != 0)
{
warning ("unable to read r_map from 0x%lx",
(long) priv->r_debug + lmo->r_map_offset);
}
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
}
}
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
std::string document = "<library-list-svr4 version=\"1.0\"";
while (lm_addr
&& read_one_ptr (lm_addr + lmo->l_name_offset,
&l_name, ptr_size) == 0
&& read_one_ptr (lm_addr + lmo->l_addr_offset,
&l_addr, ptr_size) == 0
&& read_one_ptr (lm_addr + lmo->l_ld_offset,
&l_ld, ptr_size) == 0
&& read_one_ptr (lm_addr + lmo->l_prev_offset,
&l_prev, ptr_size) == 0
&& read_one_ptr (lm_addr + lmo->l_next_offset,
&l_next, ptr_size) == 0)
{
unsigned char libname[PATH_MAX];
if (lm_prev != l_prev)
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
{
warning ("Corrupted shared library list: 0x%lx != 0x%lx",
(long) lm_prev, (long) l_prev);
break;
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
}
/* Ignore the first entry even if it has valid name as the first entry
corresponds to the main executable. The first entry should not be
skipped if the dynamic loader was loaded late by a static executable
(see solib-svr4.c parameter ignore_first). But in such case the main
executable does not have PT_DYNAMIC present and this function already
exited above due to failed get_r_debug. */
if (lm_prev == 0)
string_appendf (document, " main-lm=\"0x%lx\"", (unsigned long) lm_addr);
else
{
/* Not checking for error because reading may stop before
we've got PATH_MAX worth of characters. */
libname[0] = '\0';
linux_read_memory (l_name, libname, sizeof (libname) - 1);
libname[sizeof (libname) - 1] = '\0';
if (libname[0] != '\0')
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
{
if (!header_done)
{
/* Terminate `<library-list-svr4'. */
document += '>';
header_done = 1;
}
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
string_appendf (document, "<library name=\"");
xml_escape_text_append (&document, (char *) libname);
string_appendf (document, "\" lm=\"0x%lx\" "
"l_addr=\"0x%lx\" l_ld=\"0x%lx\"/>",
(unsigned long) lm_addr, (unsigned long) l_addr,
(unsigned long) l_ld);
}
}
lm_prev = lm_addr;
lm_addr = l_next;
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
}
if (!header_done)
{
/* Empty list; terminate `<library-list-svr4'. */
document += "/>";
}
else
document += "</library-list-svr4>";
int document_len = document.length ();
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
if (offset < document_len)
document_len -= offset;
else
document_len = 0;
if (len > document_len)
len = document_len;
memcpy (readbuf, document.data () + offset, len);
gdb/ * Makefile.in (XMLFILES): Add library-list-svr4.dtd. * features/library-list-svr4.dtd: New file. * remote.c (PACKET_qXfer_libraries_svr4): New. (remote_protocol_features): new entry for PACKET_qXfer_libraries_svr4. (remote_xfer_partial): Handle TARGET_OBJECT_LIBRARIES_SVR4. * solib-svr4.c (struct svr4_library_list): New. [HAVE_LIBEXPAT]: Include xml-support.h. [HAVE_LIBEXPAT] (svr4_library_list_start_library) [HAVE_LIBEXPAT] (svr4_library_list_start_list, svr4_library_attributes) [HAVE_LIBEXPAT] (svr4_library_list_children) [HAVE_LIBEXPAT] (svr4_library_list_attributes) [HAVE_LIBEXPAT] (svr4_library_list_elements, svr4_parse_libraries) [HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries) [!HAVE_LIBEXPAT] (svr4_current_sos_via_xfer_libraries): New. (svr4_read_so_list): Extend the corruption message by addresses. (svr4_current_sos): New variable library_list, call svr4_current_sos_via_xfer_libraries. * target.h (enum target_object): New TARGET_OBJECT_LIBRARIES_SVR4. gdb/gdbserver/ * linux-low.c (get_phdr_phnum_from_proc_auxv, get_dynamic, get_r_debug) (read_one_ptr, struct link_map_offsets, linux_qxfer_libraries_svr4): New. (struct linux_target_ops): Install linux_qxfer_libraries_svr4. * linux-low.h (struct process_info_private): New member r_debug. * server.c (handle_qxfer_libraries): Call the_target->qxfer_libraries_svr4. (handle_qxfer_libraries_svr4): New function. (qxfer_packets): New entry "libraries-svr4". (handle_query): Check QXFER_LIBRARIES_SVR4 and report libraries-svr4. * target.h (struct target_ops): New member qxfer_libraries_svr4. * remote.c (remote_xfer_partial): Call add_packet_config_cmd for PACKET_qXfer_libraries_svr4. gdb/doc/ * gdb.texinfo (Requirements, Remote Protocol): Reference also `Library List Format for SVR4 Targets'. (General Query Packets): New item qXfer:libraries-svr4:read. (Library List Format for SVR4 Targets): New node. gdb/testsuite/ * gdb.base/solib-corrupted.exp: Suppress test on is_remote target. (corrupted list): Adjust the expectation.
2011-12-02 23:26:54 +01:00
return len;
}
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
#ifdef HAVE_LINUX_BTRACE
btrace_target_info *
linux_process_target::enable_btrace (ptid_t ptid,
const btrace_config *conf)
{
return linux_enable_btrace (ptid, conf);
}
btrace, gdbserver: read branch trace incrementally Read branch trace data incrementally and extend the current trace rather than discarding it and reading the entire trace buffer each time. If the branch trace buffer overflowed, we can't extend the current trace so we discard it and start anew by reading the entire branch trace buffer. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * common/linux-btrace.c (perf_event_read_bts, linux_read_btrace): Support delta reads. (linux_disable_btrace): Change return type. * common/linux-btrace.h (linux_read_btrace): Change parameters and return type to allow error reporting. Update users. (linux_disable_btrace): Change return type. Update users. * common/btrace-common.h (btrace_read_type) <BTRACE_READ_DELTA>: New. (btrace_error): New. (btrace_block) <begin>: Comment on BEGIN == 0. * btrace.c (btrace_compute_ftrace): Start from the end of the current trace. (btrace_stitch_trace, btrace_clear_history): New. (btrace_fetch): Read delta trace, return if replaying. (btrace_clear): Move clear history code to btrace_clear_history. (parse_xml_btrace): Throw an error if parsing failed. * target.h (struct target_ops) <to_read_btrace>: Change parameters and return type to allow error reporting. (target_read_btrace): Change parameters and return type to allow error reporting. * target.c (target_read_btrace): Update. * remote.c (remote_read_btrace): Support delta reads. Pass errors on. * NEWS: Announce it. gdbserver/ * target.h (target_ops) <read_btrace>: Change parameters and return type to allow error reporting. * server.c (handle_qxfer_btrace): Support delta reads. Pass trace reading errors on. * linux-low.c (linux_low_read_btrace): Pass trace reading errors on. (linux_low_disable_btrace): New.
2013-06-03 15:39:35 +02:00
/* See to_disable_btrace target method. */
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
int
linux_process_target::disable_btrace (btrace_target_info *tinfo)
btrace, gdbserver: read branch trace incrementally Read branch trace data incrementally and extend the current trace rather than discarding it and reading the entire trace buffer each time. If the branch trace buffer overflowed, we can't extend the current trace so we discard it and start anew by reading the entire branch trace buffer. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * common/linux-btrace.c (perf_event_read_bts, linux_read_btrace): Support delta reads. (linux_disable_btrace): Change return type. * common/linux-btrace.h (linux_read_btrace): Change parameters and return type to allow error reporting. Update users. (linux_disable_btrace): Change return type. Update users. * common/btrace-common.h (btrace_read_type) <BTRACE_READ_DELTA>: New. (btrace_error): New. (btrace_block) <begin>: Comment on BEGIN == 0. * btrace.c (btrace_compute_ftrace): Start from the end of the current trace. (btrace_stitch_trace, btrace_clear_history): New. (btrace_fetch): Read delta trace, return if replaying. (btrace_clear): Move clear history code to btrace_clear_history. (parse_xml_btrace): Throw an error if parsing failed. * target.h (struct target_ops) <to_read_btrace>: Change parameters and return type to allow error reporting. (target_read_btrace): Change parameters and return type to allow error reporting. * target.c (target_read_btrace): Update. * remote.c (remote_read_btrace): Support delta reads. Pass errors on. * NEWS: Announce it. gdbserver/ * target.h (target_ops) <read_btrace>: Change parameters and return type to allow error reporting. * server.c (handle_qxfer_btrace): Support delta reads. Pass trace reading errors on. * linux-low.c (linux_low_read_btrace): Pass trace reading errors on. (linux_low_disable_btrace): New.
2013-06-03 15:39:35 +02:00
{
enum btrace_error err;
err = linux_disable_btrace (tinfo);
return (err == BTRACE_ERR_NONE ? 0 : -1);
}
/* Encode an Intel Processor Trace configuration. */
btrace: support Intel(R) Processor Trace Adds a new command "record btrace pt" to configure the kernel to use Intel(R) Processor Trace instead of Branch Trace Strore. The "record btrace" command chooses the tracing format automatically. Intel(R) Processor Trace support requires Linux 4.1 and libipt. gdb/ * NEWS: Announce new commands "record btrace pt" and "record pt". Announce new options "set|show record btrace pt buffer-size". * btrace.c: Include "rsp-low.h". Include "inttypes.h". (btrace_add_pc): Add forward declaration. (pt_reclassify_insn, ftrace_add_pt, btrace_pt_readmem_callback) (pt_translate_cpu_vendor, btrace_finalize_ftrace_pt) (btrace_compute_ftrace_pt): New. (btrace_compute_ftrace): Support BTRACE_FORMAT_PT. (check_xml_btrace_version): Update version check. (parse_xml_raw, parse_xml_btrace_pt_config_cpu) (parse_xml_btrace_pt_raw, parse_xml_btrace_pt) (btrace_pt_config_cpu_attributes, btrace_pt_config_children) (btrace_pt_children): New. (btrace_children): Add support for "pt". (parse_xml_btrace_conf_pt, btrace_conf_pt_attributes): New. (btrace_conf_children): Add support for "pt". * btrace.h: Include "intel-pt.h". (btrace_pt_error): New. * common/btrace-common.c (btrace_format_string, btrace_data_fini) (btrace_data_empty): Support BTRACE_FORMAT_PT. * common/btrace-common.h (btrace_format): Add BTRACE_FORMAT_PT. (struct btrace_config_pt): New. (struct btrace_config)<pt>: New. (struct btrace_data_pt_config, struct btrace_data_pt): New. (struct btrace_data)<pt>: New. * features/btrace-conf.dtd (btrace-conf)<pt>: New. (pt): New. * features/btrace.dtd (btrace)<pt>: New. (pt, pt-config, cpu): New. * nat/linux-btrace.c (perf_event_read, perf_event_read_all) (perf_event_pt_event_type, kernel_supports_pt) (linux_supports_pt): New. (linux_supports_btrace): Support BTRACE_FORMAT_PT. (linux_enable_bts): Free tinfo on error. (linux_enable_pt): New. (linux_enable_btrace): Support BTRACE_FORMAT_PT. (linux_disable_pt): New. (linux_disable_btrace): Support BTRACE_FORMAT_PT. (linux_fill_btrace_pt_config, linux_read_pt): New. (linux_read_btrace): Support BTRACE_FORMAT_PT. * nat/linux-btrace.h (struct btrace_tinfo_pt): New. (struct btrace_target_info)<pt>: New. * record-btrace.c (set_record_btrace_pt_cmdlist) (show_record_btrace_pt_cmdlist): New. (record_btrace_print_pt_conf): New. (record_btrace_print_conf): Support BTRACE_FORMAT_PT. (btrace_ui_out_decode_error): Support BTRACE_FORMAT_PT. (cmd_record_btrace_pt_start): New. (cmd_record_btrace_start): Support BTRACE_FORMAT_PT. (cmd_set_record_btrace_pt, cmd_show_record_btrace_pt): New. (_initialize_record_btrace): Add new commands. * remote.c (PACKET_Qbtrace_pt, PACKET_Qbtrace_conf_pt_size): New. (remote_protocol_features): Add "Qbtrace:pt". Add "Qbtrace-conf:pt:size". (remote_supports_btrace): Support BTRACE_FORMAT_PT. (btrace_sync_conf): Support PACKET_Qbtrace_conf_pt_size. (remote_enable_btrace): Support BTRACE_FORMAT_PT. (_initialize_remote): Add new commands. gdbserver/ * linux-low.c: Include "rsp-low.h" (linux_low_encode_pt_config, linux_low_encode_raw): New. (linux_low_read_btrace): Support BTRACE_FORMAT_PT. (linux_low_btrace_conf): Support BTRACE_FORMAT_PT. (handle_btrace_enable_pt): New. (handle_btrace_general_set): Support "pt". (handle_btrace_conf_general_set): Support "pt:size". doc/ * gdb.texinfo (Process Record and Replay): Spell out that variables and registers are not available during btrace replay. Describe the new "record btrace pt" command. Describe the new "set|show record btrace pt buffer-size" options. (General Query Packets): Describe the new Qbtrace:pt and Qbtrace-conf:pt:size packets. Expand "bts" to "Branch Trace Store". Update the branch trace DTD.
2014-01-24 13:45:47 +01:00
static void
linux_low_encode_pt_config (struct buffer *buffer,
const struct btrace_data_pt_config *config)
{
buffer_grow_str (buffer, "<pt-config>\n");
switch (config->cpu.vendor)
{
case CV_INTEL:
buffer_xml_printf (buffer, "<cpu vendor=\"GenuineIntel\" family=\"%u\" "
"model=\"%u\" stepping=\"%u\"/>\n",
config->cpu.family, config->cpu.model,
config->cpu.stepping);
break;
default:
break;
}
buffer_grow_str (buffer, "</pt-config>\n");
}
/* Encode a raw buffer. */
static void
linux_low_encode_raw (struct buffer *buffer, const gdb_byte *data,
unsigned int size)
{
if (size == 0)
return;
Rename common to gdbsupport This is the next patch in the ongoing series to move gdbsever to the top level. This patch just renames the "common" directory. The idea is to do this move in two parts: first rename the directory (this patch), then move the directory to the top. This approach makes the patches a bit more tractable. I chose the name "gdbsupport" for the directory. However, as this patch was largely written by sed, we could pick a new name without too much difficulty. Tested by the buildbot. gdb/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * contrib/ari/gdb_ari.sh: Change common to gdbsupport. * configure: Rebuild. * configure.ac: Change common to gdbsupport. * gdbsupport: Rename from common. * acinclude.m4: Change common to gdbsupport. * Makefile.in (CONFIG_SRC_SUBDIR, COMMON_SFILES) (HFILES_NO_SRCDIR, stamp-version, ALLDEPFILES): Change common to gdbsupport. * aarch64-tdep.c, ada-lang.c, ada-lang.h, agent.c, alloc.c, amd64-darwin-tdep.c, amd64-dicos-tdep.c, amd64-fbsd-nat.c, amd64-fbsd-tdep.c, amd64-linux-nat.c, amd64-linux-tdep.c, amd64-nbsd-tdep.c, amd64-obsd-tdep.c, amd64-sol2-tdep.c, amd64-tdep.c, amd64-windows-tdep.c, arch-utils.c, arch/aarch64-insn.c, arch/aarch64.c, arch/aarch64.h, arch/amd64.c, arch/amd64.h, arch/arm-get-next-pcs.c, arch/arm-linux.c, arch/arm.c, arch/i386.c, arch/i386.h, arch/ppc-linux-common.c, arch/riscv.c, arch/riscv.h, arch/tic6x.c, arm-tdep.c, auto-load.c, auxv.c, ax-gdb.c, ax-general.c, ax.h, breakpoint.c, breakpoint.h, btrace.c, btrace.h, build-id.c, build-id.h, c-lang.h, charset.c, charset.h, cli/cli-cmds.c, cli/cli-cmds.h, cli/cli-decode.c, cli/cli-dump.c, cli/cli-option.h, cli/cli-script.c, coff-pe-read.c, command.h, compile/compile-c-support.c, compile/compile-c.h, compile/compile-cplus-symbols.c, compile/compile-cplus-types.c, compile/compile-cplus.h, compile/compile-loc2c.c, compile/compile.c, completer.c, completer.h, contrib/ari/gdb_ari.sh, corefile.c, corelow.c, cp-support.c, cp-support.h, cp-valprint.c, csky-tdep.c, ctf.c, darwin-nat.c, debug.c, defs.h, disasm-selftests.c, disasm.c, disasm.h, dtrace-probe.c, dwarf-index-cache.c, dwarf-index-cache.h, dwarf-index-write.c, dwarf2-frame.c, dwarf2expr.c, dwarf2loc.c, dwarf2read.c, event-loop.c, event-top.c, exceptions.c, exec.c, extension.h, fbsd-nat.c, features/aarch64-core.c, features/aarch64-fpu.c, features/aarch64-pauth.c, features/aarch64-sve.c, features/i386/32bit-avx.c, features/i386/32bit-avx512.c, features/i386/32bit-core.c, features/i386/32bit-linux.c, features/i386/32bit-mpx.c, features/i386/32bit-pkeys.c, features/i386/32bit-segments.c, features/i386/32bit-sse.c, features/i386/64bit-avx.c, features/i386/64bit-avx512.c, features/i386/64bit-core.c, features/i386/64bit-linux.c, features/i386/64bit-mpx.c, features/i386/64bit-pkeys.c, features/i386/64bit-segments.c, features/i386/64bit-sse.c, features/i386/x32-core.c, features/riscv/32bit-cpu.c, features/riscv/32bit-csr.c, features/riscv/32bit-fpu.c, features/riscv/64bit-cpu.c, features/riscv/64bit-csr.c, features/riscv/64bit-fpu.c, features/tic6x-c6xp.c, features/tic6x-core.c, features/tic6x-gp.c, filename-seen-cache.h, findcmd.c, findvar.c, fork-child.c, gcore.c, gdb_bfd.c, gdb_bfd.h, gdb_proc_service.h, gdb_regex.c, gdb_select.h, gdb_usleep.c, gdbarch-selftests.c, gdbthread.h, gdbtypes.h, gnu-nat.c, go32-nat.c, guile/guile.c, guile/scm-ports.c, guile/scm-safe-call.c, guile/scm-type.c, i386-fbsd-nat.c, i386-fbsd-tdep.c, i386-go32-tdep.c, i386-linux-nat.c, i386-linux-tdep.c, i386-tdep.c, i387-tdep.c, ia64-libunwind-tdep.c, ia64-linux-nat.c, inf-child.c, inf-ptrace.c, infcall.c, infcall.h, infcmd.c, inferior-iter.h, inferior.c, inferior.h, inflow.c, inflow.h, infrun.c, infrun.h, inline-frame.c, language.h, linespec.c, linux-fork.c, linux-nat.c, linux-tdep.c, linux-thread-db.c, location.c, machoread.c, macrotab.h, main.c, maint.c, maint.h, memattr.c, memrange.h, mi/mi-cmd-break.h, mi/mi-cmd-env.c, mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-interp.c, mi/mi-main.c, mi/mi-parse.h, minsyms.c, mips-linux-tdep.c, namespace.h, nat/aarch64-linux-hw-point.c, nat/aarch64-linux-hw-point.h, nat/aarch64-linux.c, nat/aarch64-sve-linux-ptrace.c, nat/amd64-linux-siginfo.c, nat/fork-inferior.c, nat/linux-btrace.c, nat/linux-btrace.h, nat/linux-namespaces.c, nat/linux-nat.h, nat/linux-osdata.c, nat/linux-personality.c, nat/linux-procfs.c, nat/linux-ptrace.c, nat/linux-ptrace.h, nat/linux-waitpid.c, nat/mips-linux-watch.c, nat/mips-linux-watch.h, nat/ppc-linux.c, nat/x86-dregs.c, nat/x86-dregs.h, nat/x86-linux-dregs.c, nat/x86-linux.c, nto-procfs.c, nto-tdep.c, objfile-flags.h, objfiles.c, objfiles.h, obsd-nat.c, observable.h, osdata.c, p-valprint.c, parse.c, parser-defs.h, ppc-linux-nat.c, printcmd.c, probe.c, proc-api.c, procfs.c, producer.c, progspace.h, psymtab.h, python/py-framefilter.c, python/py-inferior.c, python/py-ref.h, python/py-type.c, python/python.c, record-btrace.c, record-full.c, record.c, record.h, regcache-dump.c, regcache.c, regcache.h, remote-fileio.c, remote-fileio.h, remote-sim.c, remote.c, riscv-tdep.c, rs6000-aix-tdep.c, rust-exp.y, s12z-tdep.c, selftest-arch.c, ser-base.c, ser-event.c, ser-pipe.c, ser-tcp.c, ser-unix.c, skip.c, solib-aix.c, solib-target.c, solib.c, source-cache.c, source.c, source.h, sparc-nat.c, spu-linux-nat.c, stack.c, stap-probe.c, symfile-add-flags.h, symfile.c, symfile.h, symtab.c, symtab.h, target-descriptions.c, target-descriptions.h, target-memory.c, target.c, target.h, target/waitstatus.c, target/waitstatus.h, thread-iter.h, thread.c, tilegx-tdep.c, top.c, top.h, tracefile-tfile.c, tracefile.c, tracepoint.c, tracepoint.h, tui/tui-io.c, ui-file.c, ui-out.h, unittests/array-view-selftests.c, unittests/child-path-selftests.c, unittests/cli-utils-selftests.c, unittests/common-utils-selftests.c, unittests/copy_bitwise-selftests.c, unittests/environ-selftests.c, unittests/format_pieces-selftests.c, unittests/function-view-selftests.c, unittests/lookup_name_info-selftests.c, unittests/memory-map-selftests.c, unittests/memrange-selftests.c, unittests/mkdir-recursive-selftests.c, unittests/observable-selftests.c, unittests/offset-type-selftests.c, unittests/optional-selftests.c, unittests/parse-connection-spec-selftests.c, unittests/ptid-selftests.c, unittests/rsp-low-selftests.c, unittests/scoped_fd-selftests.c, unittests/scoped_mmap-selftests.c, unittests/scoped_restore-selftests.c, unittests/string_view-selftests.c, unittests/style-selftests.c, unittests/tracepoint-selftests.c, unittests/unpack-selftests.c, unittests/utils-selftests.c, unittests/xml-utils-selftests.c, utils.c, utils.h, valarith.c, valops.c, valprint.c, value.c, value.h, varobj.c, varobj.h, windows-nat.c, x86-linux-nat.c, xml-support.c, xml-support.h, xml-tdesc.h, xstormy16-tdep.c, xtensa-linux-nat.c, dwarf2read.h: Change common to gdbsupport. gdb/gdbserver/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * configure: Rebuild. * configure.ac: Change common to gdbsupport. * acinclude.m4: Change common to gdbsupport. * Makefile.in (SFILES, OBS, GDBREPLAY_OBS, IPA_OBJS) (version-generated.c, gdbsupport/%-ipa.o, gdbsupport/%.o): Change common to gdbsupport. * ax.c, event-loop.c, fork-child.c, gdb_proc_service.h, gdbreplay.c, gdbthread.h, hostio-errno.c, hostio.c, i387-fp.c, inferiors.c, inferiors.h, linux-aarch64-tdesc-selftest.c, linux-amd64-ipa.c, linux-i386-ipa.c, linux-low.c, linux-tic6x-low.c, linux-x86-low.c, linux-x86-tdesc-selftest.c, linux-x86-tdesc.c, lynx-i386-low.c, lynx-low.c, mem-break.h, nto-x86-low.c, regcache.c, regcache.h, remote-utils.c, server.c, server.h, spu-low.c, symbol.c, target.h, tdesc.c, tdesc.h, thread-db.c, tracepoint.c, win32-i386-low.c, win32-low.c: Change common to gdbsupport.
2019-05-06 04:29:24 +02:00
/* We use hex encoding - see gdbsupport/rsp-low.h. */
btrace: support Intel(R) Processor Trace Adds a new command "record btrace pt" to configure the kernel to use Intel(R) Processor Trace instead of Branch Trace Strore. The "record btrace" command chooses the tracing format automatically. Intel(R) Processor Trace support requires Linux 4.1 and libipt. gdb/ * NEWS: Announce new commands "record btrace pt" and "record pt". Announce new options "set|show record btrace pt buffer-size". * btrace.c: Include "rsp-low.h". Include "inttypes.h". (btrace_add_pc): Add forward declaration. (pt_reclassify_insn, ftrace_add_pt, btrace_pt_readmem_callback) (pt_translate_cpu_vendor, btrace_finalize_ftrace_pt) (btrace_compute_ftrace_pt): New. (btrace_compute_ftrace): Support BTRACE_FORMAT_PT. (check_xml_btrace_version): Update version check. (parse_xml_raw, parse_xml_btrace_pt_config_cpu) (parse_xml_btrace_pt_raw, parse_xml_btrace_pt) (btrace_pt_config_cpu_attributes, btrace_pt_config_children) (btrace_pt_children): New. (btrace_children): Add support for "pt". (parse_xml_btrace_conf_pt, btrace_conf_pt_attributes): New. (btrace_conf_children): Add support for "pt". * btrace.h: Include "intel-pt.h". (btrace_pt_error): New. * common/btrace-common.c (btrace_format_string, btrace_data_fini) (btrace_data_empty): Support BTRACE_FORMAT_PT. * common/btrace-common.h (btrace_format): Add BTRACE_FORMAT_PT. (struct btrace_config_pt): New. (struct btrace_config)<pt>: New. (struct btrace_data_pt_config, struct btrace_data_pt): New. (struct btrace_data)<pt>: New. * features/btrace-conf.dtd (btrace-conf)<pt>: New. (pt): New. * features/btrace.dtd (btrace)<pt>: New. (pt, pt-config, cpu): New. * nat/linux-btrace.c (perf_event_read, perf_event_read_all) (perf_event_pt_event_type, kernel_supports_pt) (linux_supports_pt): New. (linux_supports_btrace): Support BTRACE_FORMAT_PT. (linux_enable_bts): Free tinfo on error. (linux_enable_pt): New. (linux_enable_btrace): Support BTRACE_FORMAT_PT. (linux_disable_pt): New. (linux_disable_btrace): Support BTRACE_FORMAT_PT. (linux_fill_btrace_pt_config, linux_read_pt): New. (linux_read_btrace): Support BTRACE_FORMAT_PT. * nat/linux-btrace.h (struct btrace_tinfo_pt): New. (struct btrace_target_info)<pt>: New. * record-btrace.c (set_record_btrace_pt_cmdlist) (show_record_btrace_pt_cmdlist): New. (record_btrace_print_pt_conf): New. (record_btrace_print_conf): Support BTRACE_FORMAT_PT. (btrace_ui_out_decode_error): Support BTRACE_FORMAT_PT. (cmd_record_btrace_pt_start): New. (cmd_record_btrace_start): Support BTRACE_FORMAT_PT. (cmd_set_record_btrace_pt, cmd_show_record_btrace_pt): New. (_initialize_record_btrace): Add new commands. * remote.c (PACKET_Qbtrace_pt, PACKET_Qbtrace_conf_pt_size): New. (remote_protocol_features): Add "Qbtrace:pt". Add "Qbtrace-conf:pt:size". (remote_supports_btrace): Support BTRACE_FORMAT_PT. (btrace_sync_conf): Support PACKET_Qbtrace_conf_pt_size. (remote_enable_btrace): Support BTRACE_FORMAT_PT. (_initialize_remote): Add new commands. gdbserver/ * linux-low.c: Include "rsp-low.h" (linux_low_encode_pt_config, linux_low_encode_raw): New. (linux_low_read_btrace): Support BTRACE_FORMAT_PT. (linux_low_btrace_conf): Support BTRACE_FORMAT_PT. (handle_btrace_enable_pt): New. (handle_btrace_general_set): Support "pt". (handle_btrace_conf_general_set): Support "pt:size". doc/ * gdb.texinfo (Process Record and Replay): Spell out that variables and registers are not available during btrace replay. Describe the new "record btrace pt" command. Describe the new "set|show record btrace pt buffer-size" options. (General Query Packets): Describe the new Qbtrace:pt and Qbtrace-conf:pt:size packets. Expand "bts" to "Branch Trace Store". Update the branch trace DTD.
2014-01-24 13:45:47 +01:00
buffer_grow_str (buffer, "<raw>\n");
while (size-- > 0)
{
char elem[2];
elem[0] = tohex ((*data >> 4) & 0xf);
elem[1] = tohex (*data++ & 0xf);
buffer_grow (buffer, elem, 2);
}
buffer_grow_str (buffer, "</raw>\n");
}
btrace, gdbserver: read branch trace incrementally Read branch trace data incrementally and extend the current trace rather than discarding it and reading the entire trace buffer each time. If the branch trace buffer overflowed, we can't extend the current trace so we discard it and start anew by reading the entire branch trace buffer. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * common/linux-btrace.c (perf_event_read_bts, linux_read_btrace): Support delta reads. (linux_disable_btrace): Change return type. * common/linux-btrace.h (linux_read_btrace): Change parameters and return type to allow error reporting. Update users. (linux_disable_btrace): Change return type. Update users. * common/btrace-common.h (btrace_read_type) <BTRACE_READ_DELTA>: New. (btrace_error): New. (btrace_block) <begin>: Comment on BEGIN == 0. * btrace.c (btrace_compute_ftrace): Start from the end of the current trace. (btrace_stitch_trace, btrace_clear_history): New. (btrace_fetch): Read delta trace, return if replaying. (btrace_clear): Move clear history code to btrace_clear_history. (parse_xml_btrace): Throw an error if parsing failed. * target.h (struct target_ops) <to_read_btrace>: Change parameters and return type to allow error reporting. (target_read_btrace): Change parameters and return type to allow error reporting. * target.c (target_read_btrace): Update. * remote.c (remote_read_btrace): Support delta reads. Pass errors on. * NEWS: Announce it. gdbserver/ * target.h (target_ops) <read_btrace>: Change parameters and return type to allow error reporting. * server.c (handle_qxfer_btrace): Support delta reads. Pass trace reading errors on. * linux-low.c (linux_low_read_btrace): Pass trace reading errors on. (linux_low_disable_btrace): New.
2013-06-03 15:39:35 +02:00
/* See to_read_btrace target method. */
int
linux_process_target::read_btrace (btrace_target_info *tinfo,
buffer *buffer,
enum btrace_read_type type)
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
{
btrace: add struct btrace_data Add a structure to hold the branch trace data and an enum to describe the format of that data. So far, only BTS is supported. Also added a NONE format to indicate that no branch trace data is available. This will make it easier to support different branch trace formats in the future. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * Makefile.in (SFILES): Add common/btrace-common.c. (COMMON_OBS): Add common/btrace-common.o. (btrace-common.o): Add build rules. * btrace.c (parse_xml_btrace): Update parameters. (parse_xml_btrace_block): Set format field. (btrace_add_pc, btrace_fetch): Use struct btrace_data. (do_btrace_data_cleanup, make_cleanup_btrace_data): New. (btrace_compute_ftrace): Split into this and... (btrace_compute_ftrace_bts): ...this. (btrace_stitch_trace): Split into this and... (btrace_stitch_bts): ...this. * btrace.h (parse_xml_btrace): Update parameters. (make_cleanup_btrace_data): New. * common/btrace-common.c: New. * common/btrace-common.h: Include common-defs.h. (btrace_block_s): Update comment. (btrace_format): New. (btrace_format_string): New. (btrace_data_bts): New. (btrace_data): New. (btrace_data_init, btrace_data_fini, btrace_data_empty): New. * remote.c (remote_read_btrace): Update parameters. * target.c (target_read_btrace): Update parameters. * target.h (target_read_btrace): Update parameters. (target_ops)<to_read_btrace>: Update parameters. * x86-linux-nat.c (x86_linux_read_btrace): Update parameters. * target-delegates.c: Regenerate. * target-debug (target_debug_print_struct_btrace_data_p): New. * nat/linux-btrace.c (linux_read_btrace): Split into this and... (linux_read_bts): ...this. * nat/linux-btrace.h (linux_read_btrace): Update parameters. gdbserver/ * Makefile.in (SFILES): Add common/btrace-common.c. (OBS): Add common/btrace-common.o. (btrace-common.o): Add build rules. * linux-low: Include btrace-common.h. (linux_low_read_btrace): Use struct btrace_data. Call btrace_data_init and btrace_data_fini.
2013-11-13 15:31:07 +01:00
struct btrace_data btrace;
btrace, gdbserver: read branch trace incrementally Read branch trace data incrementally and extend the current trace rather than discarding it and reading the entire trace buffer each time. If the branch trace buffer overflowed, we can't extend the current trace so we discard it and start anew by reading the entire branch trace buffer. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * common/linux-btrace.c (perf_event_read_bts, linux_read_btrace): Support delta reads. (linux_disable_btrace): Change return type. * common/linux-btrace.h (linux_read_btrace): Change parameters and return type to allow error reporting. Update users. (linux_disable_btrace): Change return type. Update users. * common/btrace-common.h (btrace_read_type) <BTRACE_READ_DELTA>: New. (btrace_error): New. (btrace_block) <begin>: Comment on BEGIN == 0. * btrace.c (btrace_compute_ftrace): Start from the end of the current trace. (btrace_stitch_trace, btrace_clear_history): New. (btrace_fetch): Read delta trace, return if replaying. (btrace_clear): Move clear history code to btrace_clear_history. (parse_xml_btrace): Throw an error if parsing failed. * target.h (struct target_ops) <to_read_btrace>: Change parameters and return type to allow error reporting. (target_read_btrace): Change parameters and return type to allow error reporting. * target.c (target_read_btrace): Update. * remote.c (remote_read_btrace): Support delta reads. Pass errors on. * NEWS: Announce it. gdbserver/ * target.h (target_ops) <read_btrace>: Change parameters and return type to allow error reporting. * server.c (handle_qxfer_btrace): Support delta reads. Pass trace reading errors on. * linux-low.c (linux_low_read_btrace): Pass trace reading errors on. (linux_low_disable_btrace): New.
2013-06-03 15:39:35 +02:00
enum btrace_error err;
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
btrace, gdbserver: read branch trace incrementally Read branch trace data incrementally and extend the current trace rather than discarding it and reading the entire trace buffer each time. If the branch trace buffer overflowed, we can't extend the current trace so we discard it and start anew by reading the entire branch trace buffer. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * common/linux-btrace.c (perf_event_read_bts, linux_read_btrace): Support delta reads. (linux_disable_btrace): Change return type. * common/linux-btrace.h (linux_read_btrace): Change parameters and return type to allow error reporting. Update users. (linux_disable_btrace): Change return type. Update users. * common/btrace-common.h (btrace_read_type) <BTRACE_READ_DELTA>: New. (btrace_error): New. (btrace_block) <begin>: Comment on BEGIN == 0. * btrace.c (btrace_compute_ftrace): Start from the end of the current trace. (btrace_stitch_trace, btrace_clear_history): New. (btrace_fetch): Read delta trace, return if replaying. (btrace_clear): Move clear history code to btrace_clear_history. (parse_xml_btrace): Throw an error if parsing failed. * target.h (struct target_ops) <to_read_btrace>: Change parameters and return type to allow error reporting. (target_read_btrace): Change parameters and return type to allow error reporting. * target.c (target_read_btrace): Update. * remote.c (remote_read_btrace): Support delta reads. Pass errors on. * NEWS: Announce it. gdbserver/ * target.h (target_ops) <read_btrace>: Change parameters and return type to allow error reporting. * server.c (handle_qxfer_btrace): Support delta reads. Pass trace reading errors on. * linux-low.c (linux_low_read_btrace): Pass trace reading errors on. (linux_low_disable_btrace): New.
2013-06-03 15:39:35 +02:00
err = linux_read_btrace (&btrace, tinfo, type);
if (err != BTRACE_ERR_NONE)
{
if (err == BTRACE_ERR_OVERFLOW)
buffer_grow_str0 (buffer, "E.Overflow.");
else
buffer_grow_str0 (buffer, "E.Generic Error.");
return -1;
btrace, gdbserver: read branch trace incrementally Read branch trace data incrementally and extend the current trace rather than discarding it and reading the entire trace buffer each time. If the branch trace buffer overflowed, we can't extend the current trace so we discard it and start anew by reading the entire branch trace buffer. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * common/linux-btrace.c (perf_event_read_bts, linux_read_btrace): Support delta reads. (linux_disable_btrace): Change return type. * common/linux-btrace.h (linux_read_btrace): Change parameters and return type to allow error reporting. Update users. (linux_disable_btrace): Change return type. Update users. * common/btrace-common.h (btrace_read_type) <BTRACE_READ_DELTA>: New. (btrace_error): New. (btrace_block) <begin>: Comment on BEGIN == 0. * btrace.c (btrace_compute_ftrace): Start from the end of the current trace. (btrace_stitch_trace, btrace_clear_history): New. (btrace_fetch): Read delta trace, return if replaying. (btrace_clear): Move clear history code to btrace_clear_history. (parse_xml_btrace): Throw an error if parsing failed. * target.h (struct target_ops) <to_read_btrace>: Change parameters and return type to allow error reporting. (target_read_btrace): Change parameters and return type to allow error reporting. * target.c (target_read_btrace): Update. * remote.c (remote_read_btrace): Support delta reads. Pass errors on. * NEWS: Announce it. gdbserver/ * target.h (target_ops) <read_btrace>: Change parameters and return type to allow error reporting. * server.c (handle_qxfer_btrace): Support delta reads. Pass trace reading errors on. * linux-low.c (linux_low_read_btrace): Pass trace reading errors on. (linux_low_disable_btrace): New.
2013-06-03 15:39:35 +02:00
}
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
btrace: add struct btrace_data Add a structure to hold the branch trace data and an enum to describe the format of that data. So far, only BTS is supported. Also added a NONE format to indicate that no branch trace data is available. This will make it easier to support different branch trace formats in the future. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * Makefile.in (SFILES): Add common/btrace-common.c. (COMMON_OBS): Add common/btrace-common.o. (btrace-common.o): Add build rules. * btrace.c (parse_xml_btrace): Update parameters. (parse_xml_btrace_block): Set format field. (btrace_add_pc, btrace_fetch): Use struct btrace_data. (do_btrace_data_cleanup, make_cleanup_btrace_data): New. (btrace_compute_ftrace): Split into this and... (btrace_compute_ftrace_bts): ...this. (btrace_stitch_trace): Split into this and... (btrace_stitch_bts): ...this. * btrace.h (parse_xml_btrace): Update parameters. (make_cleanup_btrace_data): New. * common/btrace-common.c: New. * common/btrace-common.h: Include common-defs.h. (btrace_block_s): Update comment. (btrace_format): New. (btrace_format_string): New. (btrace_data_bts): New. (btrace_data): New. (btrace_data_init, btrace_data_fini, btrace_data_empty): New. * remote.c (remote_read_btrace): Update parameters. * target.c (target_read_btrace): Update parameters. * target.h (target_read_btrace): Update parameters. (target_ops)<to_read_btrace>: Update parameters. * x86-linux-nat.c (x86_linux_read_btrace): Update parameters. * target-delegates.c: Regenerate. * target-debug (target_debug_print_struct_btrace_data_p): New. * nat/linux-btrace.c (linux_read_btrace): Split into this and... (linux_read_bts): ...this. * nat/linux-btrace.h (linux_read_btrace): Update parameters. gdbserver/ * Makefile.in (SFILES): Add common/btrace-common.c. (OBS): Add common/btrace-common.o. (btrace-common.o): Add build rules. * linux-low: Include btrace-common.h. (linux_low_read_btrace): Use struct btrace_data. Call btrace_data_init and btrace_data_fini.
2013-11-13 15:31:07 +01:00
switch (btrace.format)
{
case BTRACE_FORMAT_NONE:
buffer_grow_str0 (buffer, "E.No Trace.");
return -1;
btrace: add struct btrace_data Add a structure to hold the branch trace data and an enum to describe the format of that data. So far, only BTS is supported. Also added a NONE format to indicate that no branch trace data is available. This will make it easier to support different branch trace formats in the future. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * Makefile.in (SFILES): Add common/btrace-common.c. (COMMON_OBS): Add common/btrace-common.o. (btrace-common.o): Add build rules. * btrace.c (parse_xml_btrace): Update parameters. (parse_xml_btrace_block): Set format field. (btrace_add_pc, btrace_fetch): Use struct btrace_data. (do_btrace_data_cleanup, make_cleanup_btrace_data): New. (btrace_compute_ftrace): Split into this and... (btrace_compute_ftrace_bts): ...this. (btrace_stitch_trace): Split into this and... (btrace_stitch_bts): ...this. * btrace.h (parse_xml_btrace): Update parameters. (make_cleanup_btrace_data): New. * common/btrace-common.c: New. * common/btrace-common.h: Include common-defs.h. (btrace_block_s): Update comment. (btrace_format): New. (btrace_format_string): New. (btrace_data_bts): New. (btrace_data): New. (btrace_data_init, btrace_data_fini, btrace_data_empty): New. * remote.c (remote_read_btrace): Update parameters. * target.c (target_read_btrace): Update parameters. * target.h (target_read_btrace): Update parameters. (target_ops)<to_read_btrace>: Update parameters. * x86-linux-nat.c (x86_linux_read_btrace): Update parameters. * target-delegates.c: Regenerate. * target-debug (target_debug_print_struct_btrace_data_p): New. * nat/linux-btrace.c (linux_read_btrace): Split into this and... (linux_read_bts): ...this. * nat/linux-btrace.h (linux_read_btrace): Update parameters. gdbserver/ * Makefile.in (SFILES): Add common/btrace-common.c. (OBS): Add common/btrace-common.o. (btrace-common.o): Add build rules. * linux-low: Include btrace-common.h. (linux_low_read_btrace): Use struct btrace_data. Call btrace_data_init and btrace_data_fini.
2013-11-13 15:31:07 +01:00
case BTRACE_FORMAT_BTS:
buffer_grow_str (buffer, "<!DOCTYPE btrace SYSTEM \"btrace.dtd\">\n");
buffer_grow_str (buffer, "<btrace version=\"1.0\">\n");
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
for (const btrace_block &block : *btrace.variant.bts.blocks)
btrace: add struct btrace_data Add a structure to hold the branch trace data and an enum to describe the format of that data. So far, only BTS is supported. Also added a NONE format to indicate that no branch trace data is available. This will make it easier to support different branch trace formats in the future. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * Makefile.in (SFILES): Add common/btrace-common.c. (COMMON_OBS): Add common/btrace-common.o. (btrace-common.o): Add build rules. * btrace.c (parse_xml_btrace): Update parameters. (parse_xml_btrace_block): Set format field. (btrace_add_pc, btrace_fetch): Use struct btrace_data. (do_btrace_data_cleanup, make_cleanup_btrace_data): New. (btrace_compute_ftrace): Split into this and... (btrace_compute_ftrace_bts): ...this. (btrace_stitch_trace): Split into this and... (btrace_stitch_bts): ...this. * btrace.h (parse_xml_btrace): Update parameters. (make_cleanup_btrace_data): New. * common/btrace-common.c: New. * common/btrace-common.h: Include common-defs.h. (btrace_block_s): Update comment. (btrace_format): New. (btrace_format_string): New. (btrace_data_bts): New. (btrace_data): New. (btrace_data_init, btrace_data_fini, btrace_data_empty): New. * remote.c (remote_read_btrace): Update parameters. * target.c (target_read_btrace): Update parameters. * target.h (target_read_btrace): Update parameters. (target_ops)<to_read_btrace>: Update parameters. * x86-linux-nat.c (x86_linux_read_btrace): Update parameters. * target-delegates.c: Regenerate. * target-debug (target_debug_print_struct_btrace_data_p): New. * nat/linux-btrace.c (linux_read_btrace): Split into this and... (linux_read_bts): ...this. * nat/linux-btrace.h (linux_read_btrace): Update parameters. gdbserver/ * Makefile.in (SFILES): Add common/btrace-common.c. (OBS): Add common/btrace-common.o. (btrace-common.o): Add build rules. * linux-low: Include btrace-common.h. (linux_low_read_btrace): Use struct btrace_data. Call btrace_data_init and btrace_data_fini.
2013-11-13 15:31:07 +01:00
buffer_xml_printf (buffer, "<block begin=\"0x%s\" end=\"0x%s\"/>\n",
paddress (block.begin), paddress (block.end));
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
btrace: add struct btrace_data Add a structure to hold the branch trace data and an enum to describe the format of that data. So far, only BTS is supported. Also added a NONE format to indicate that no branch trace data is available. This will make it easier to support different branch trace formats in the future. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * Makefile.in (SFILES): Add common/btrace-common.c. (COMMON_OBS): Add common/btrace-common.o. (btrace-common.o): Add build rules. * btrace.c (parse_xml_btrace): Update parameters. (parse_xml_btrace_block): Set format field. (btrace_add_pc, btrace_fetch): Use struct btrace_data. (do_btrace_data_cleanup, make_cleanup_btrace_data): New. (btrace_compute_ftrace): Split into this and... (btrace_compute_ftrace_bts): ...this. (btrace_stitch_trace): Split into this and... (btrace_stitch_bts): ...this. * btrace.h (parse_xml_btrace): Update parameters. (make_cleanup_btrace_data): New. * common/btrace-common.c: New. * common/btrace-common.h: Include common-defs.h. (btrace_block_s): Update comment. (btrace_format): New. (btrace_format_string): New. (btrace_data_bts): New. (btrace_data): New. (btrace_data_init, btrace_data_fini, btrace_data_empty): New. * remote.c (remote_read_btrace): Update parameters. * target.c (target_read_btrace): Update parameters. * target.h (target_read_btrace): Update parameters. (target_ops)<to_read_btrace>: Update parameters. * x86-linux-nat.c (x86_linux_read_btrace): Update parameters. * target-delegates.c: Regenerate. * target-debug (target_debug_print_struct_btrace_data_p): New. * nat/linux-btrace.c (linux_read_btrace): Split into this and... (linux_read_bts): ...this. * nat/linux-btrace.h (linux_read_btrace): Update parameters. gdbserver/ * Makefile.in (SFILES): Add common/btrace-common.c. (OBS): Add common/btrace-common.o. (btrace-common.o): Add build rules. * linux-low: Include btrace-common.h. (linux_low_read_btrace): Use struct btrace_data. Call btrace_data_init and btrace_data_fini.
2013-11-13 15:31:07 +01:00
buffer_grow_str0 (buffer, "</btrace>\n");
break;
btrace: support Intel(R) Processor Trace Adds a new command "record btrace pt" to configure the kernel to use Intel(R) Processor Trace instead of Branch Trace Strore. The "record btrace" command chooses the tracing format automatically. Intel(R) Processor Trace support requires Linux 4.1 and libipt. gdb/ * NEWS: Announce new commands "record btrace pt" and "record pt". Announce new options "set|show record btrace pt buffer-size". * btrace.c: Include "rsp-low.h". Include "inttypes.h". (btrace_add_pc): Add forward declaration. (pt_reclassify_insn, ftrace_add_pt, btrace_pt_readmem_callback) (pt_translate_cpu_vendor, btrace_finalize_ftrace_pt) (btrace_compute_ftrace_pt): New. (btrace_compute_ftrace): Support BTRACE_FORMAT_PT. (check_xml_btrace_version): Update version check. (parse_xml_raw, parse_xml_btrace_pt_config_cpu) (parse_xml_btrace_pt_raw, parse_xml_btrace_pt) (btrace_pt_config_cpu_attributes, btrace_pt_config_children) (btrace_pt_children): New. (btrace_children): Add support for "pt". (parse_xml_btrace_conf_pt, btrace_conf_pt_attributes): New. (btrace_conf_children): Add support for "pt". * btrace.h: Include "intel-pt.h". (btrace_pt_error): New. * common/btrace-common.c (btrace_format_string, btrace_data_fini) (btrace_data_empty): Support BTRACE_FORMAT_PT. * common/btrace-common.h (btrace_format): Add BTRACE_FORMAT_PT. (struct btrace_config_pt): New. (struct btrace_config)<pt>: New. (struct btrace_data_pt_config, struct btrace_data_pt): New. (struct btrace_data)<pt>: New. * features/btrace-conf.dtd (btrace-conf)<pt>: New. (pt): New. * features/btrace.dtd (btrace)<pt>: New. (pt, pt-config, cpu): New. * nat/linux-btrace.c (perf_event_read, perf_event_read_all) (perf_event_pt_event_type, kernel_supports_pt) (linux_supports_pt): New. (linux_supports_btrace): Support BTRACE_FORMAT_PT. (linux_enable_bts): Free tinfo on error. (linux_enable_pt): New. (linux_enable_btrace): Support BTRACE_FORMAT_PT. (linux_disable_pt): New. (linux_disable_btrace): Support BTRACE_FORMAT_PT. (linux_fill_btrace_pt_config, linux_read_pt): New. (linux_read_btrace): Support BTRACE_FORMAT_PT. * nat/linux-btrace.h (struct btrace_tinfo_pt): New. (struct btrace_target_info)<pt>: New. * record-btrace.c (set_record_btrace_pt_cmdlist) (show_record_btrace_pt_cmdlist): New. (record_btrace_print_pt_conf): New. (record_btrace_print_conf): Support BTRACE_FORMAT_PT. (btrace_ui_out_decode_error): Support BTRACE_FORMAT_PT. (cmd_record_btrace_pt_start): New. (cmd_record_btrace_start): Support BTRACE_FORMAT_PT. (cmd_set_record_btrace_pt, cmd_show_record_btrace_pt): New. (_initialize_record_btrace): Add new commands. * remote.c (PACKET_Qbtrace_pt, PACKET_Qbtrace_conf_pt_size): New. (remote_protocol_features): Add "Qbtrace:pt". Add "Qbtrace-conf:pt:size". (remote_supports_btrace): Support BTRACE_FORMAT_PT. (btrace_sync_conf): Support PACKET_Qbtrace_conf_pt_size. (remote_enable_btrace): Support BTRACE_FORMAT_PT. (_initialize_remote): Add new commands. gdbserver/ * linux-low.c: Include "rsp-low.h" (linux_low_encode_pt_config, linux_low_encode_raw): New. (linux_low_read_btrace): Support BTRACE_FORMAT_PT. (linux_low_btrace_conf): Support BTRACE_FORMAT_PT. (handle_btrace_enable_pt): New. (handle_btrace_general_set): Support "pt". (handle_btrace_conf_general_set): Support "pt:size". doc/ * gdb.texinfo (Process Record and Replay): Spell out that variables and registers are not available during btrace replay. Describe the new "record btrace pt" command. Describe the new "set|show record btrace pt buffer-size" options. (General Query Packets): Describe the new Qbtrace:pt and Qbtrace-conf:pt:size packets. Expand "bts" to "Branch Trace Store". Update the branch trace DTD.
2014-01-24 13:45:47 +01:00
case BTRACE_FORMAT_PT:
buffer_grow_str (buffer, "<!DOCTYPE btrace SYSTEM \"btrace.dtd\">\n");
buffer_grow_str (buffer, "<btrace version=\"1.0\">\n");
buffer_grow_str (buffer, "<pt>\n");
linux_low_encode_pt_config (buffer, &btrace.variant.pt.config);
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
btrace: support Intel(R) Processor Trace Adds a new command "record btrace pt" to configure the kernel to use Intel(R) Processor Trace instead of Branch Trace Strore. The "record btrace" command chooses the tracing format automatically. Intel(R) Processor Trace support requires Linux 4.1 and libipt. gdb/ * NEWS: Announce new commands "record btrace pt" and "record pt". Announce new options "set|show record btrace pt buffer-size". * btrace.c: Include "rsp-low.h". Include "inttypes.h". (btrace_add_pc): Add forward declaration. (pt_reclassify_insn, ftrace_add_pt, btrace_pt_readmem_callback) (pt_translate_cpu_vendor, btrace_finalize_ftrace_pt) (btrace_compute_ftrace_pt): New. (btrace_compute_ftrace): Support BTRACE_FORMAT_PT. (check_xml_btrace_version): Update version check. (parse_xml_raw, parse_xml_btrace_pt_config_cpu) (parse_xml_btrace_pt_raw, parse_xml_btrace_pt) (btrace_pt_config_cpu_attributes, btrace_pt_config_children) (btrace_pt_children): New. (btrace_children): Add support for "pt". (parse_xml_btrace_conf_pt, btrace_conf_pt_attributes): New. (btrace_conf_children): Add support for "pt". * btrace.h: Include "intel-pt.h". (btrace_pt_error): New. * common/btrace-common.c (btrace_format_string, btrace_data_fini) (btrace_data_empty): Support BTRACE_FORMAT_PT. * common/btrace-common.h (btrace_format): Add BTRACE_FORMAT_PT. (struct btrace_config_pt): New. (struct btrace_config)<pt>: New. (struct btrace_data_pt_config, struct btrace_data_pt): New. (struct btrace_data)<pt>: New. * features/btrace-conf.dtd (btrace-conf)<pt>: New. (pt): New. * features/btrace.dtd (btrace)<pt>: New. (pt, pt-config, cpu): New. * nat/linux-btrace.c (perf_event_read, perf_event_read_all) (perf_event_pt_event_type, kernel_supports_pt) (linux_supports_pt): New. (linux_supports_btrace): Support BTRACE_FORMAT_PT. (linux_enable_bts): Free tinfo on error. (linux_enable_pt): New. (linux_enable_btrace): Support BTRACE_FORMAT_PT. (linux_disable_pt): New. (linux_disable_btrace): Support BTRACE_FORMAT_PT. (linux_fill_btrace_pt_config, linux_read_pt): New. (linux_read_btrace): Support BTRACE_FORMAT_PT. * nat/linux-btrace.h (struct btrace_tinfo_pt): New. (struct btrace_target_info)<pt>: New. * record-btrace.c (set_record_btrace_pt_cmdlist) (show_record_btrace_pt_cmdlist): New. (record_btrace_print_pt_conf): New. (record_btrace_print_conf): Support BTRACE_FORMAT_PT. (btrace_ui_out_decode_error): Support BTRACE_FORMAT_PT. (cmd_record_btrace_pt_start): New. (cmd_record_btrace_start): Support BTRACE_FORMAT_PT. (cmd_set_record_btrace_pt, cmd_show_record_btrace_pt): New. (_initialize_record_btrace): Add new commands. * remote.c (PACKET_Qbtrace_pt, PACKET_Qbtrace_conf_pt_size): New. (remote_protocol_features): Add "Qbtrace:pt". Add "Qbtrace-conf:pt:size". (remote_supports_btrace): Support BTRACE_FORMAT_PT. (btrace_sync_conf): Support PACKET_Qbtrace_conf_pt_size. (remote_enable_btrace): Support BTRACE_FORMAT_PT. (_initialize_remote): Add new commands. gdbserver/ * linux-low.c: Include "rsp-low.h" (linux_low_encode_pt_config, linux_low_encode_raw): New. (linux_low_read_btrace): Support BTRACE_FORMAT_PT. (linux_low_btrace_conf): Support BTRACE_FORMAT_PT. (handle_btrace_enable_pt): New. (handle_btrace_general_set): Support "pt". (handle_btrace_conf_general_set): Support "pt:size". doc/ * gdb.texinfo (Process Record and Replay): Spell out that variables and registers are not available during btrace replay. Describe the new "record btrace pt" command. Describe the new "set|show record btrace pt buffer-size" options. (General Query Packets): Describe the new Qbtrace:pt and Qbtrace-conf:pt:size packets. Expand "bts" to "Branch Trace Store". Update the branch trace DTD.
2014-01-24 13:45:47 +01:00
linux_low_encode_raw (buffer, btrace.variant.pt.data,
btrace.variant.pt.size);
buffer_grow_str (buffer, "</pt>\n");
buffer_grow_str0 (buffer, "</btrace>\n");
break;
default:
buffer_grow_str0 (buffer, "E.Unsupported Trace Format.");
return -1;
btrace: add struct btrace_data Add a structure to hold the branch trace data and an enum to describe the format of that data. So far, only BTS is supported. Also added a NONE format to indicate that no branch trace data is available. This will make it easier to support different branch trace formats in the future. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * Makefile.in (SFILES): Add common/btrace-common.c. (COMMON_OBS): Add common/btrace-common.o. (btrace-common.o): Add build rules. * btrace.c (parse_xml_btrace): Update parameters. (parse_xml_btrace_block): Set format field. (btrace_add_pc, btrace_fetch): Use struct btrace_data. (do_btrace_data_cleanup, make_cleanup_btrace_data): New. (btrace_compute_ftrace): Split into this and... (btrace_compute_ftrace_bts): ...this. (btrace_stitch_trace): Split into this and... (btrace_stitch_bts): ...this. * btrace.h (parse_xml_btrace): Update parameters. (make_cleanup_btrace_data): New. * common/btrace-common.c: New. * common/btrace-common.h: Include common-defs.h. (btrace_block_s): Update comment. (btrace_format): New. (btrace_format_string): New. (btrace_data_bts): New. (btrace_data): New. (btrace_data_init, btrace_data_fini, btrace_data_empty): New. * remote.c (remote_read_btrace): Update parameters. * target.c (target_read_btrace): Update parameters. * target.h (target_read_btrace): Update parameters. (target_ops)<to_read_btrace>: Update parameters. * x86-linux-nat.c (x86_linux_read_btrace): Update parameters. * target-delegates.c: Regenerate. * target-debug (target_debug_print_struct_btrace_data_p): New. * nat/linux-btrace.c (linux_read_btrace): Split into this and... (linux_read_bts): ...this. * nat/linux-btrace.h (linux_read_btrace): Update parameters. gdbserver/ * Makefile.in (SFILES): Add common/btrace-common.c. (OBS): Add common/btrace-common.o. (btrace-common.o): Add build rules. * linux-low: Include btrace-common.h. (linux_low_read_btrace): Use struct btrace_data. Call btrace_data_init and btrace_data_fini.
2013-11-13 15:31:07 +01:00
}
btrace, gdbserver: read branch trace incrementally Read branch trace data incrementally and extend the current trace rather than discarding it and reading the entire trace buffer each time. If the branch trace buffer overflowed, we can't extend the current trace so we discard it and start anew by reading the entire branch trace buffer. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * common/linux-btrace.c (perf_event_read_bts, linux_read_btrace): Support delta reads. (linux_disable_btrace): Change return type. * common/linux-btrace.h (linux_read_btrace): Change parameters and return type to allow error reporting. Update users. (linux_disable_btrace): Change return type. Update users. * common/btrace-common.h (btrace_read_type) <BTRACE_READ_DELTA>: New. (btrace_error): New. (btrace_block) <begin>: Comment on BEGIN == 0. * btrace.c (btrace_compute_ftrace): Start from the end of the current trace. (btrace_stitch_trace, btrace_clear_history): New. (btrace_fetch): Read delta trace, return if replaying. (btrace_clear): Move clear history code to btrace_clear_history. (parse_xml_btrace): Throw an error if parsing failed. * target.h (struct target_ops) <to_read_btrace>: Change parameters and return type to allow error reporting. (target_read_btrace): Change parameters and return type to allow error reporting. * target.c (target_read_btrace): Update. * remote.c (remote_read_btrace): Support delta reads. Pass errors on. * NEWS: Announce it. gdbserver/ * target.h (target_ops) <read_btrace>: Change parameters and return type to allow error reporting. * server.c (handle_qxfer_btrace): Support delta reads. Pass trace reading errors on. * linux-low.c (linux_low_read_btrace): Pass trace reading errors on. (linux_low_disable_btrace): New.
2013-06-03 15:39:35 +02:00
return 0;
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
}
record btrace: add configuration struct Add a struct to describe the branch trace configuration and use it for enabling branch tracing. The user will be able to set configuration fields for each tracing format to be used for new threads. The actual configuration that is active for a given thread will be shown in the "info record" command. At the moment, the configuration struct only contains a format field that is set to the only available format. The format is the only configuration option that can not be set via set commands. It is given as argument to the "record btrace" command when starting recording. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * Makefile.in (XMLFILES): Add btrace-conf.dtd. * x86-linux-nat.c (x86_linux_enable_btrace): Update parameters. (x86_linux_btrace_conf): New. (x86_linux_create_target): Initialize to_btrace_conf. * nat/linux-btrace.c (linux_enable_btrace): Update parameters. Check format. Split into this and ... (linux_enable_bts): ... this. (linux_btrace_conf): New. (perf_event_skip_record): Renamed into ... (perf_event_skip_bts_record): ... this. Updated users. (linux_disable_btrace): Split into this and ... (linux_disable_bts): ... this. (linux_read_btrace): Check format. * nat/linux-btrace.h (linux_enable_btrace): Update parameters. (linux_btrace_conf): New. (btrace_target_info)<ptid>: Moved. (btrace_target_info)<conf>: New. (btrace_target_info): Split into this and ... (btrace_tinfo_bts): ... this. Updated users. * btrace.c (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf_bts, parse_xml_btrace_conf) (btrace_conf_children, btrace_conf_attributes) (btrace_conf_elements): New. * btrace.h (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf): New. * common/btrace-common.h (btrace_config): New. * feature/btrace-conf.dtd: New. * record-btrace.c (record_btrace_conf): New. (record_btrace_cmdlist): New. (record_btrace_enable_warn, record_btrace_open): Pass &record_btrace_conf. (record_btrace_info): Print recording format. (cmd_record_btrace_bts_start): New. (cmd_record_btrace_start): Call cmd_record_btrace_bts_start. (_initialize_record_btrace): Add "record btrace bts" subcommand. Add "record bts" alias command. * remote.c (remote_state)<btrace_config>: New. (remote_btrace_reset, PACKET_qXfer_btrace_conf): New. (remote_protocol_features): Add qXfer:btrace-conf:read. (remote_open_1): Call remote_btrace_reset. (remote_xfer_partial): Handle TARGET_OBJECT_BTRACE_CONF. (btrace_target_info)<conf>: New. (btrace_sync_conf, btrace_read_config): New. (remote_enable_btrace): Update parameters. Call btrace_sync_conf and btrace_read_conf. (remote_btrace_conf): New. (init_remote_ops): Initialize to_btrace_conf. (_initialize_remote): Add qXfer:btrace-conf packet. * target.c (target_enable_btrace): Update parameters. (target_btrace_conf): New. * target.h (target_enable_btrace): Update parameters. (target_btrace_conf): New. (target_object)<TARGET_OBJECT_BTRACE_CONF>: New. (target_ops)<to_enable_btrace>: Update parameters and comment. (target_ops)<to_btrace_conf>: New. * target-delegates: Regenerate. * target-debug.h (target_debug_print_const_struct_btrace_config_p) (target_debug_print_const_struct_btrace_target_info_p): New. NEWS: Announce new command and new packet. doc/ * gdb.texinfo (Process Record and Replay): Describe the "record btrace bts" command. (General Query Packets): Describe qXfer:btrace-conf:read packet. (Branch Trace Configuration Format): New. gdbserver/ * linux-low.c (linux_low_enable_btrace): Update parameters. (linux_low_btrace_conf): New. (linux_target_ops)<to_btrace_conf>: Initialize. * server.c (current_btrace_conf): New. (handle_btrace_enable): Rename to ... (handle_btrace_enable_bts): ... this. Pass &current_btrace_conf to target_enable_btrace. Update comment. Update users. (handle_qxfer_btrace_conf): New. (qxfer_packets): Add btrace-conf entry. (handle_query): Report qXfer:btrace-conf:read as supported packet. * target.h (target_ops)<enable_btrace>: Update parameters and comment. (target_ops)<read_btrace_conf>: New. (target_enable_btrace): Update parameters. (target_read_btrace_conf): New. testsuite/ * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2013-11-28 15:44:13 +01:00
/* See to_btrace_conf target method. */
int
linux_process_target::read_btrace_conf (const btrace_target_info *tinfo,
buffer *buffer)
record btrace: add configuration struct Add a struct to describe the branch trace configuration and use it for enabling branch tracing. The user will be able to set configuration fields for each tracing format to be used for new threads. The actual configuration that is active for a given thread will be shown in the "info record" command. At the moment, the configuration struct only contains a format field that is set to the only available format. The format is the only configuration option that can not be set via set commands. It is given as argument to the "record btrace" command when starting recording. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * Makefile.in (XMLFILES): Add btrace-conf.dtd. * x86-linux-nat.c (x86_linux_enable_btrace): Update parameters. (x86_linux_btrace_conf): New. (x86_linux_create_target): Initialize to_btrace_conf. * nat/linux-btrace.c (linux_enable_btrace): Update parameters. Check format. Split into this and ... (linux_enable_bts): ... this. (linux_btrace_conf): New. (perf_event_skip_record): Renamed into ... (perf_event_skip_bts_record): ... this. Updated users. (linux_disable_btrace): Split into this and ... (linux_disable_bts): ... this. (linux_read_btrace): Check format. * nat/linux-btrace.h (linux_enable_btrace): Update parameters. (linux_btrace_conf): New. (btrace_target_info)<ptid>: Moved. (btrace_target_info)<conf>: New. (btrace_target_info): Split into this and ... (btrace_tinfo_bts): ... this. Updated users. * btrace.c (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf_bts, parse_xml_btrace_conf) (btrace_conf_children, btrace_conf_attributes) (btrace_conf_elements): New. * btrace.h (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf): New. * common/btrace-common.h (btrace_config): New. * feature/btrace-conf.dtd: New. * record-btrace.c (record_btrace_conf): New. (record_btrace_cmdlist): New. (record_btrace_enable_warn, record_btrace_open): Pass &record_btrace_conf. (record_btrace_info): Print recording format. (cmd_record_btrace_bts_start): New. (cmd_record_btrace_start): Call cmd_record_btrace_bts_start. (_initialize_record_btrace): Add "record btrace bts" subcommand. Add "record bts" alias command. * remote.c (remote_state)<btrace_config>: New. (remote_btrace_reset, PACKET_qXfer_btrace_conf): New. (remote_protocol_features): Add qXfer:btrace-conf:read. (remote_open_1): Call remote_btrace_reset. (remote_xfer_partial): Handle TARGET_OBJECT_BTRACE_CONF. (btrace_target_info)<conf>: New. (btrace_sync_conf, btrace_read_config): New. (remote_enable_btrace): Update parameters. Call btrace_sync_conf and btrace_read_conf. (remote_btrace_conf): New. (init_remote_ops): Initialize to_btrace_conf. (_initialize_remote): Add qXfer:btrace-conf packet. * target.c (target_enable_btrace): Update parameters. (target_btrace_conf): New. * target.h (target_enable_btrace): Update parameters. (target_btrace_conf): New. (target_object)<TARGET_OBJECT_BTRACE_CONF>: New. (target_ops)<to_enable_btrace>: Update parameters and comment. (target_ops)<to_btrace_conf>: New. * target-delegates: Regenerate. * target-debug.h (target_debug_print_const_struct_btrace_config_p) (target_debug_print_const_struct_btrace_target_info_p): New. NEWS: Announce new command and new packet. doc/ * gdb.texinfo (Process Record and Replay): Describe the "record btrace bts" command. (General Query Packets): Describe qXfer:btrace-conf:read packet. (Branch Trace Configuration Format): New. gdbserver/ * linux-low.c (linux_low_enable_btrace): Update parameters. (linux_low_btrace_conf): New. (linux_target_ops)<to_btrace_conf>: Initialize. * server.c (current_btrace_conf): New. (handle_btrace_enable): Rename to ... (handle_btrace_enable_bts): ... this. Pass &current_btrace_conf to target_enable_btrace. Update comment. Update users. (handle_qxfer_btrace_conf): New. (qxfer_packets): Add btrace-conf entry. (handle_query): Report qXfer:btrace-conf:read as supported packet. * target.h (target_ops)<enable_btrace>: Update parameters and comment. (target_ops)<read_btrace_conf>: New. (target_enable_btrace): Update parameters. (target_read_btrace_conf): New. testsuite/ * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2013-11-28 15:44:13 +01:00
{
const struct btrace_config *conf;
buffer_grow_str (buffer, "<!DOCTYPE btrace-conf SYSTEM \"btrace-conf.dtd\">\n");
buffer_grow_str (buffer, "<btrace-conf version=\"1.0\">\n");
conf = linux_btrace_conf (tinfo);
if (conf != NULL)
{
switch (conf->format)
{
case BTRACE_FORMAT_NONE:
break;
case BTRACE_FORMAT_BTS:
record-btrace: add bts buffer size configuration option Allow the size of the branch trace ring buffer to be defined by the user. The specified buffer size will be used when BTS tracing is enabled for new threads. The obtained buffer size may differ from the requested size. The actual buffer size for the current thread is shown in the "info record" command. Bigger buffers mean longer traces, but also longer processing time. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (parse_xml_btrace_conf_bts): Add size. (btrace_conf_bts_attributes): New. (btrace_conf_children): Add attributes. * common/btrace-common.h (btrace_config_bts): New. (btrace_config)<bts>: New. (btrace_config): Update comment. * nat/linux-btrace.c (linux_enable_btrace, linux_enable_bts): Use config. * features/btrace-conf.dtd: Increment version. Add size attribute to bts element. * record-btrace.c (set_record_btrace_bts_cmdlist, show_record_btrace_bts_cmdlist): New. (record_btrace_adjust_size, record_btrace_print_bts_conf, record_btrace_print_conf, cmd_set_record_btrace_bts, cmd_show_record_btrace_bts): New. (record_btrace_info): Call record_btrace_print_conf. (_initialize_record_btrace): Add commands. * remote.c: Add PACKET_Qbtrace_conf_bts_size enum. (remote_protocol_features): Add Qbtrace-conf:bts:size packet. (btrace_sync_conf): Synchronize bts size. (_initialize_remote): Add Qbtrace-conf:bts:size packet. * NEWS: Announce new commands and new packets. doc/ * gdb.texinfo (Branch Trace Configuration Format): Add size. (Process Record and Replay): Describe new set|show commands. (General Query Packets): Describe Qbtrace-conf:bts:size packet. testsuite/ * gdb.btrace/buffer-size: New. gdbserver/ * linux-low.c (linux_low_btrace_conf): Print size. * server.c (handle_btrace_conf_general_set): New. (hanle_general_set): Call handle_btrace_conf_general_set. (handle_query): Report Qbtrace-conf:bts:size as supported.
2013-11-28 16:39:12 +01:00
buffer_xml_printf (buffer, "<bts");
buffer_xml_printf (buffer, " size=\"0x%x\"", conf->bts.size);
buffer_xml_printf (buffer, " />\n");
record btrace: add configuration struct Add a struct to describe the branch trace configuration and use it for enabling branch tracing. The user will be able to set configuration fields for each tracing format to be used for new threads. The actual configuration that is active for a given thread will be shown in the "info record" command. At the moment, the configuration struct only contains a format field that is set to the only available format. The format is the only configuration option that can not be set via set commands. It is given as argument to the "record btrace" command when starting recording. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * Makefile.in (XMLFILES): Add btrace-conf.dtd. * x86-linux-nat.c (x86_linux_enable_btrace): Update parameters. (x86_linux_btrace_conf): New. (x86_linux_create_target): Initialize to_btrace_conf. * nat/linux-btrace.c (linux_enable_btrace): Update parameters. Check format. Split into this and ... (linux_enable_bts): ... this. (linux_btrace_conf): New. (perf_event_skip_record): Renamed into ... (perf_event_skip_bts_record): ... this. Updated users. (linux_disable_btrace): Split into this and ... (linux_disable_bts): ... this. (linux_read_btrace): Check format. * nat/linux-btrace.h (linux_enable_btrace): Update parameters. (linux_btrace_conf): New. (btrace_target_info)<ptid>: Moved. (btrace_target_info)<conf>: New. (btrace_target_info): Split into this and ... (btrace_tinfo_bts): ... this. Updated users. * btrace.c (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf_bts, parse_xml_btrace_conf) (btrace_conf_children, btrace_conf_attributes) (btrace_conf_elements): New. * btrace.h (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf): New. * common/btrace-common.h (btrace_config): New. * feature/btrace-conf.dtd: New. * record-btrace.c (record_btrace_conf): New. (record_btrace_cmdlist): New. (record_btrace_enable_warn, record_btrace_open): Pass &record_btrace_conf. (record_btrace_info): Print recording format. (cmd_record_btrace_bts_start): New. (cmd_record_btrace_start): Call cmd_record_btrace_bts_start. (_initialize_record_btrace): Add "record btrace bts" subcommand. Add "record bts" alias command. * remote.c (remote_state)<btrace_config>: New. (remote_btrace_reset, PACKET_qXfer_btrace_conf): New. (remote_protocol_features): Add qXfer:btrace-conf:read. (remote_open_1): Call remote_btrace_reset. (remote_xfer_partial): Handle TARGET_OBJECT_BTRACE_CONF. (btrace_target_info)<conf>: New. (btrace_sync_conf, btrace_read_config): New. (remote_enable_btrace): Update parameters. Call btrace_sync_conf and btrace_read_conf. (remote_btrace_conf): New. (init_remote_ops): Initialize to_btrace_conf. (_initialize_remote): Add qXfer:btrace-conf packet. * target.c (target_enable_btrace): Update parameters. (target_btrace_conf): New. * target.h (target_enable_btrace): Update parameters. (target_btrace_conf): New. (target_object)<TARGET_OBJECT_BTRACE_CONF>: New. (target_ops)<to_enable_btrace>: Update parameters and comment. (target_ops)<to_btrace_conf>: New. * target-delegates: Regenerate. * target-debug.h (target_debug_print_const_struct_btrace_config_p) (target_debug_print_const_struct_btrace_target_info_p): New. NEWS: Announce new command and new packet. doc/ * gdb.texinfo (Process Record and Replay): Describe the "record btrace bts" command. (General Query Packets): Describe qXfer:btrace-conf:read packet. (Branch Trace Configuration Format): New. gdbserver/ * linux-low.c (linux_low_enable_btrace): Update parameters. (linux_low_btrace_conf): New. (linux_target_ops)<to_btrace_conf>: Initialize. * server.c (current_btrace_conf): New. (handle_btrace_enable): Rename to ... (handle_btrace_enable_bts): ... this. Pass &current_btrace_conf to target_enable_btrace. Update comment. Update users. (handle_qxfer_btrace_conf): New. (qxfer_packets): Add btrace-conf entry. (handle_query): Report qXfer:btrace-conf:read as supported packet. * target.h (target_ops)<enable_btrace>: Update parameters and comment. (target_ops)<read_btrace_conf>: New. (target_enable_btrace): Update parameters. (target_read_btrace_conf): New. testsuite/ * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2013-11-28 15:44:13 +01:00
break;
btrace: support Intel(R) Processor Trace Adds a new command "record btrace pt" to configure the kernel to use Intel(R) Processor Trace instead of Branch Trace Strore. The "record btrace" command chooses the tracing format automatically. Intel(R) Processor Trace support requires Linux 4.1 and libipt. gdb/ * NEWS: Announce new commands "record btrace pt" and "record pt". Announce new options "set|show record btrace pt buffer-size". * btrace.c: Include "rsp-low.h". Include "inttypes.h". (btrace_add_pc): Add forward declaration. (pt_reclassify_insn, ftrace_add_pt, btrace_pt_readmem_callback) (pt_translate_cpu_vendor, btrace_finalize_ftrace_pt) (btrace_compute_ftrace_pt): New. (btrace_compute_ftrace): Support BTRACE_FORMAT_PT. (check_xml_btrace_version): Update version check. (parse_xml_raw, parse_xml_btrace_pt_config_cpu) (parse_xml_btrace_pt_raw, parse_xml_btrace_pt) (btrace_pt_config_cpu_attributes, btrace_pt_config_children) (btrace_pt_children): New. (btrace_children): Add support for "pt". (parse_xml_btrace_conf_pt, btrace_conf_pt_attributes): New. (btrace_conf_children): Add support for "pt". * btrace.h: Include "intel-pt.h". (btrace_pt_error): New. * common/btrace-common.c (btrace_format_string, btrace_data_fini) (btrace_data_empty): Support BTRACE_FORMAT_PT. * common/btrace-common.h (btrace_format): Add BTRACE_FORMAT_PT. (struct btrace_config_pt): New. (struct btrace_config)<pt>: New. (struct btrace_data_pt_config, struct btrace_data_pt): New. (struct btrace_data)<pt>: New. * features/btrace-conf.dtd (btrace-conf)<pt>: New. (pt): New. * features/btrace.dtd (btrace)<pt>: New. (pt, pt-config, cpu): New. * nat/linux-btrace.c (perf_event_read, perf_event_read_all) (perf_event_pt_event_type, kernel_supports_pt) (linux_supports_pt): New. (linux_supports_btrace): Support BTRACE_FORMAT_PT. (linux_enable_bts): Free tinfo on error. (linux_enable_pt): New. (linux_enable_btrace): Support BTRACE_FORMAT_PT. (linux_disable_pt): New. (linux_disable_btrace): Support BTRACE_FORMAT_PT. (linux_fill_btrace_pt_config, linux_read_pt): New. (linux_read_btrace): Support BTRACE_FORMAT_PT. * nat/linux-btrace.h (struct btrace_tinfo_pt): New. (struct btrace_target_info)<pt>: New. * record-btrace.c (set_record_btrace_pt_cmdlist) (show_record_btrace_pt_cmdlist): New. (record_btrace_print_pt_conf): New. (record_btrace_print_conf): Support BTRACE_FORMAT_PT. (btrace_ui_out_decode_error): Support BTRACE_FORMAT_PT. (cmd_record_btrace_pt_start): New. (cmd_record_btrace_start): Support BTRACE_FORMAT_PT. (cmd_set_record_btrace_pt, cmd_show_record_btrace_pt): New. (_initialize_record_btrace): Add new commands. * remote.c (PACKET_Qbtrace_pt, PACKET_Qbtrace_conf_pt_size): New. (remote_protocol_features): Add "Qbtrace:pt". Add "Qbtrace-conf:pt:size". (remote_supports_btrace): Support BTRACE_FORMAT_PT. (btrace_sync_conf): Support PACKET_Qbtrace_conf_pt_size. (remote_enable_btrace): Support BTRACE_FORMAT_PT. (_initialize_remote): Add new commands. gdbserver/ * linux-low.c: Include "rsp-low.h" (linux_low_encode_pt_config, linux_low_encode_raw): New. (linux_low_read_btrace): Support BTRACE_FORMAT_PT. (linux_low_btrace_conf): Support BTRACE_FORMAT_PT. (handle_btrace_enable_pt): New. (handle_btrace_general_set): Support "pt". (handle_btrace_conf_general_set): Support "pt:size". doc/ * gdb.texinfo (Process Record and Replay): Spell out that variables and registers are not available during btrace replay. Describe the new "record btrace pt" command. Describe the new "set|show record btrace pt buffer-size" options. (General Query Packets): Describe the new Qbtrace:pt and Qbtrace-conf:pt:size packets. Expand "bts" to "Branch Trace Store". Update the branch trace DTD.
2014-01-24 13:45:47 +01:00
case BTRACE_FORMAT_PT:
buffer_xml_printf (buffer, "<pt");
buffer_xml_printf (buffer, " size=\"0x%x\"", conf->pt.size);
buffer_xml_printf (buffer, "/>\n");
break;
record btrace: add configuration struct Add a struct to describe the branch trace configuration and use it for enabling branch tracing. The user will be able to set configuration fields for each tracing format to be used for new threads. The actual configuration that is active for a given thread will be shown in the "info record" command. At the moment, the configuration struct only contains a format field that is set to the only available format. The format is the only configuration option that can not be set via set commands. It is given as argument to the "record btrace" command when starting recording. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * Makefile.in (XMLFILES): Add btrace-conf.dtd. * x86-linux-nat.c (x86_linux_enable_btrace): Update parameters. (x86_linux_btrace_conf): New. (x86_linux_create_target): Initialize to_btrace_conf. * nat/linux-btrace.c (linux_enable_btrace): Update parameters. Check format. Split into this and ... (linux_enable_bts): ... this. (linux_btrace_conf): New. (perf_event_skip_record): Renamed into ... (perf_event_skip_bts_record): ... this. Updated users. (linux_disable_btrace): Split into this and ... (linux_disable_bts): ... this. (linux_read_btrace): Check format. * nat/linux-btrace.h (linux_enable_btrace): Update parameters. (linux_btrace_conf): New. (btrace_target_info)<ptid>: Moved. (btrace_target_info)<conf>: New. (btrace_target_info): Split into this and ... (btrace_tinfo_bts): ... this. Updated users. * btrace.c (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf_bts, parse_xml_btrace_conf) (btrace_conf_children, btrace_conf_attributes) (btrace_conf_elements): New. * btrace.h (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf): New. * common/btrace-common.h (btrace_config): New. * feature/btrace-conf.dtd: New. * record-btrace.c (record_btrace_conf): New. (record_btrace_cmdlist): New. (record_btrace_enable_warn, record_btrace_open): Pass &record_btrace_conf. (record_btrace_info): Print recording format. (cmd_record_btrace_bts_start): New. (cmd_record_btrace_start): Call cmd_record_btrace_bts_start. (_initialize_record_btrace): Add "record btrace bts" subcommand. Add "record bts" alias command. * remote.c (remote_state)<btrace_config>: New. (remote_btrace_reset, PACKET_qXfer_btrace_conf): New. (remote_protocol_features): Add qXfer:btrace-conf:read. (remote_open_1): Call remote_btrace_reset. (remote_xfer_partial): Handle TARGET_OBJECT_BTRACE_CONF. (btrace_target_info)<conf>: New. (btrace_sync_conf, btrace_read_config): New. (remote_enable_btrace): Update parameters. Call btrace_sync_conf and btrace_read_conf. (remote_btrace_conf): New. (init_remote_ops): Initialize to_btrace_conf. (_initialize_remote): Add qXfer:btrace-conf packet. * target.c (target_enable_btrace): Update parameters. (target_btrace_conf): New. * target.h (target_enable_btrace): Update parameters. (target_btrace_conf): New. (target_object)<TARGET_OBJECT_BTRACE_CONF>: New. (target_ops)<to_enable_btrace>: Update parameters and comment. (target_ops)<to_btrace_conf>: New. * target-delegates: Regenerate. * target-debug.h (target_debug_print_const_struct_btrace_config_p) (target_debug_print_const_struct_btrace_target_info_p): New. NEWS: Announce new command and new packet. doc/ * gdb.texinfo (Process Record and Replay): Describe the "record btrace bts" command. (General Query Packets): Describe qXfer:btrace-conf:read packet. (Branch Trace Configuration Format): New. gdbserver/ * linux-low.c (linux_low_enable_btrace): Update parameters. (linux_low_btrace_conf): New. (linux_target_ops)<to_btrace_conf>: Initialize. * server.c (current_btrace_conf): New. (handle_btrace_enable): Rename to ... (handle_btrace_enable_bts): ... this. Pass &current_btrace_conf to target_enable_btrace. Update comment. Update users. (handle_qxfer_btrace_conf): New. (qxfer_packets): Add btrace-conf entry. (handle_query): Report qXfer:btrace-conf:read as supported packet. * target.h (target_ops)<enable_btrace>: Update parameters and comment. (target_ops)<read_btrace_conf>: New. (target_enable_btrace): Update parameters. (target_read_btrace_conf): New. testsuite/ * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2013-11-28 15:44:13 +01:00
}
}
buffer_grow_str0 (buffer, "</btrace-conf>\n");
return 0;
}
Add the gdb remote target operations for branch tracing. We define the following packets: Qbtrace:bts enable branch tracing for the current thread returns "OK" or "Enn" Qbtrace:off disable branch tracing for the current thread returns "OK" or "Enn" qXfer:btrace:read read the full branch trace data for the current thread gdb/ * target.h (enum target_object): Add TARGET_OBJECT_BTRACE. * remote.c: Include btrace.h. (struct btrace_target_info): New struct. (remote_supports_btrace): New function. (send_Qbtrace): New function. (remote_enable_btrace): New function. (remote_disable_btrace): New function. (remote_teardown_btrace): New function. (remote_read_btrace): New function. (init_remote_ops): Add btrace ops. (enum <unnamed>): Add btrace packets. (struct protocol_feature remote_protocol_features[]): Add btrace packets. (_initialize_remote): Add packet configuration for branch tracing. gdbserver/ * target.h (struct target_ops): Add btrace ops. (target_supports_btrace): New macro. (target_enable_btrace): New macro. (target_disable_btrace): New macro. (target_read_btrace): New macro. * gdbthread.h (struct thread_info): Add btrace field. * server.c: Include btrace-common.h. (handle_btrace_general_set): New function. (handle_btrace_enable): New function. (handle_btrace_disable): New function. (handle_general_set): Call handle_btrace_general_set. (handle_qxfer_btrace): New function. (struct qxfer qxfer_packets[]): Add btrace entry. * inferiors.c (remove_thread): Disable btrace. * linux-low: Include linux-btrace.h. (linux_low_enable_btrace): New function. (linux_low_read_btrace): New function. (linux_target_ops): Add btrace ops. * configure.srv (i[34567]86-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. (x86_64-*-linux*): Add linux-btrace.o. Add srv_linux_btrace=yes. * configure.ac: Define HAVE_LINUX_BTRACE. * config.in: Regenerated. * configure: Regenerated.
2013-03-11 09:35:11 +01:00
#endif /* HAVE_LINUX_BTRACE */
/* See nat/linux-nat.h. */
ptid_t
current_lwp_ptid (void)
{
return ptid_of (current_thread);
}
const char *
linux_process_target::thread_name (ptid_t thread)
{
return linux_proc_tid_get_name (thread);
}
#if USE_THREAD_DB
bool
linux_process_target::thread_handle (ptid_t ptid, gdb_byte **handle,
int *handle_len)
{
return thread_db_thread_handle (ptid, handle, handle_len);
}
#endif
Replace some $ARCH_{get,set}_pc with linux_{get,set}_pc_32bit This patch adds a pair of new functions linux_get_pc_32bit and linux_set_pc_32bit which get and set 32-bit register "pc" from regcache. This function can be used some targets and these own $ARCH_{get,set}_pc are replaced by linux_{get,set}_pc_32bit respectively. This patch touches many targets, but I only have arm board to test and no regression. I also rebuilt nios2-linux GDBserver. If it is right to go, I'll post the 64-bit counterpart later. gdb/gdbserver: 2016-01-18 Yao Qi <yao.qi@linaro.org> * linux-arm-low.c (debug_threads): Remove declaration. (arm_get_pc, arm_set_pc): Remove. (the_low_target): Use linux_get_pc_32bit and linux_set_pc_32bit. * linux-bfin-low.c (bfin_get_pc, bfin_set_pc): Remove. (the_low_target): Use linux_get_pc_32bit and linux_set_pc_32bit. * linux-cris-low.c (debug_threads): Remove declaration. (cris_get_pc, cris_set_pc,): Remove. (the_low_target): Use linux_get_pc_32bit and linux_set_pc_32bit. * linux-crisv32-low.c (debug_threads): Remove declaration. (cris_get_pc, cris_set_pc): Remove. (the_low_target): Use linux_get_pc_32bit and linux_set_pc_32bit. * linux-low.c: Include inttypes.h. (linux_get_pc_32bit, linux_set_pc_32bit): New functions. * linux-low.h (linux_get_pc_32bit, linux_set_pc_32bit): Declare. * linux-m32r-low.c (m32r_get_pc, m32r_set_pc): Remove. (the_low_target): Use linux_get_pc_32bit and linux_set_pc_32bit. * linux-m68k-low.c (m68k_get_pc, m68k_set_pc): Remove. (the_low_target): Use linux_get_pc_32bit and linux_set_pc_32bit. * linux-nios2-low.c (nios2_get_pc, nios2_set_pc): Remove. (the_low_target): Use linux_get_pc_32bit and linux_set_pc_32bit. * linux-sh-low.c (sh_get_pc, sh_set_pc): Remove. (the_low_target): Use linux_get_pc_32bit and linux_set_pc_32bit. * linux-xtensa-low.c (xtensa_get_pc, xtensa_set_pc): Remove. (the_low_target): Use linux_get_pc_32bit and linux_set_pc_32bit.
2016-01-18 15:49:50 +01:00
/* Default implementation of linux_target_ops method "set_pc" for
32-bit pc register which is literally named "pc". */
void
linux_set_pc_32bit (struct regcache *regcache, CORE_ADDR pc)
{
uint32_t newpc = pc;
supply_register_by_name (regcache, "pc", &newpc);
}
/* Default implementation of linux_target_ops method "get_pc" for
32-bit pc register which is literally named "pc". */
CORE_ADDR
linux_get_pc_32bit (struct regcache *regcache)
{
uint32_t pc;
collect_register_by_name (regcache, "pc", &pc);
if (debug_threads)
debug_printf ("stop pc is 0x%" PRIx32 "\n", pc);
return pc;
}
/* Default implementation of linux_target_ops method "set_pc" for
64-bit pc register which is literally named "pc". */
void
linux_set_pc_64bit (struct regcache *regcache, CORE_ADDR pc)
{
uint64_t newpc = pc;
supply_register_by_name (regcache, "pc", &newpc);
}
/* Default implementation of linux_target_ops method "get_pc" for
64-bit pc register which is literally named "pc". */
CORE_ADDR
linux_get_pc_64bit (struct regcache *regcache)
{
uint64_t pc;
collect_register_by_name (regcache, "pc", &pc);
if (debug_threads)
debug_printf ("stop pc is 0x%" PRIx64 "\n", pc);
return pc;
}
/* See linux-low.h. */
int
linux_get_auxv (int wordsize, CORE_ADDR match, CORE_ADDR *valp)
{
gdb_byte *data = (gdb_byte *) alloca (2 * wordsize);
int offset = 0;
gdb_assert (wordsize == 4 || wordsize == 8);
gdbserver: finish turning the target ops vector into a class Now that 'process_stratum_target' has a single field left, namely 'pt' of type 'process_target', and that all the requests to a 'process_stratum_target' are forwarded to 'pt', meld the 'process_target' class into 'process_stratum_target'. This essentially means 1. All the references of the form 'the_target->pt' become 'the_target'. 2. All the uses of the name 'process_target' become 'process_stratum_target'. 3. The platform-specific target op vectors (e.g. linux_target_ops) are removed and instances of their "process target" classes are used instead. gdbserver/ChangeLog: 2020-02-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * target.h (struct process_stratum_target): Remove. (class process_target): Rename to ... (class process_stratum_target): ... this. * linux-low.h (class linux_process_target): Derive from 'process_stratum_target'. * linux-low.cc (linux_target_ops): Remove. (initialize_low): Set the_target to the singleton instance of linux_process_target. * lynx-low.h (class lynx_process_target): Derive from 'process_stratum_target'. * lynx-low.cc (lynx_target_ops): Remove. (initialize_low): Set the_target to the singleton instance of lynx_process_target. * nto-low.h (class nto_process_target): Derive from 'process_stratum_target'. * nto-low.cc (nto_target_ops): Remove. (initialize_low): Set the_target to the singleton instance of nto_process_target. * win32-low.h (class win32_process_target): Derive from 'process_stratum_target'. * win32-low.cc (win32_target_ops): Remove. (initialize_low): Set the_target to the singleton instance of win32_process_target. Replace 'the_target->pt' with 'the_target' in the uses below. * hostio.cc (hostio_error) (handle_setfs) (handle_open) (handle_unlink) (handle_readlink) * linux-aarch32-low.cc (arm_breakpoint_at) * linux-aarch64-low.cc (aarch64_breakpoint_at) * linux-arm-low.cc (arm_sigreturn_next_pc) (arm_get_hwcap) (arm_get_syscall_trapinfo) * linux-cris-low.cc (cris_breakpoint_at) * linux-crisv32-low.cc (cris_breakpoint_at) * linux-low.cc (handle_extended_wait) (linux_wait_1) (linux_read_memory) (linux_process_target::breakpoint_kind_from_pc) (linux_get_auxv) * linux-m32r-low.cc (m32r_breakpoint_at) * linux-mips-low.cc (mips_breakpoint_at) * linux-nios2-low.cc (nios2_breakpoint_at) * linux-ppc-low.cc (ppc_breakpoint_at) * linux-s390-low.cc (s390_get_hwcap) * linux-sh-low.cc (sh_breakpoint_at) * linux-sparc-low.cc (sparc_fill_gregset_to_stack) (sparc_store_gregset_from_stack) (sparc_breakpoint_at) * linux-tic6x-low.cc (tic6x_breakpoint_at) * linux-tile-low.cc (tile_breakpoint_at) * linux-x86-low.cc (x86_breakpoint_at) * linux-xtensa-low.cc (xtensa_breakpoint_at) * mem-break.cc (bp_size) (bp_opcode) (insert_memory_breakpoint) (set_raw_breakpoint_at) (delete_raw_breakpoint) (z_type_supported) (uninsert_raw_breakpoint) (reinsert_raw_breakpoint) (validate_inserted_breakpoint) * regcache.cc (regcache_read_pc) (regcache_write_pc) * remote-utils.cc (putpkt_binary_1) (input_interrupt) (getpkt) (prepare_resume_reply) * server.cc (handle_general_set) (handle_detach) (handle_qxfer_auxv) (handle_qxfer_exec_file) (handle_qxfer_libraries_svr4) (handle_qxfer_osdata) (handle_qxfer_siginfo) (handle_qxfer_fdpic) (handle_query) (resume) (handle_v_requests) (queue_stop_reply_callback) (captured_main) * target.cc (prepare_to_access_memory) (done_accessing_memory) (read_inferior_memory) (target_write_memory) (target_stop_and_wait) (target_wait) (target_mourn_inferior) (target_continue_no_signal) (target_continue) (target_supports_multi_process) (kill_inferior) * target.h (target_create_inferior) (target_post_create_inferior) (myattach) (target_supports_fork_events) (target_supports_vfork_events) (target_supports_exec_events) (target_handle_new_gdb_connection) (detach_inferior) (mythread_alive) (fetch_inferior_registers) (store_inferior_registers) (join_inferior) (target_supports_non_stop) (target_async) (target_process_qsupported) (target_supports_catch_syscall) (target_get_ipa_tdesc_idx) (target_supports_tracepoints) (target_supports_fast_tracepoints) (target_get_min_fast_tracepoint_insn_len) (target_thread_stopped) (target_pause_all) (target_unpause_all) (target_stabilize_threads) (target_install_fast_tracepoint_jump_pad) (target_emit_ops) (target_supports_disable_randomization) (target_supports_agent) (target_enable_btrace) (target_disable_btrace) (target_read_btrace) (target_read_btrace_conf) (target_supports_range_stepping) (target_supports_stopped_by_sw_breakpoint) (target_stopped_by_sw_breakpoint) (target_supports_stopped_by_hw_breakpoint) (target_supports_hardware_single_step) (target_stopped_by_hw_breakpoint) (target_breakpoint_kind_from_pc) (target_breakpoint_kind_from_current_state) (target_supports_software_single_step) (target_core_of_thread) (target_thread_name) (target_thread_handle) * win32-low.cc (do_initial_child_stuff) Rename target op default definitions listed below. * target.cc (process_target::post_create_inferior): Rename as ... (process_stratum_target::post_create_inferior): ... this. (process_target::prepare_to_access_memory): Rename as ... (process_stratum_target::prepare_to_access_memory): ... this. (process_target::done_accessing_memory): Rename as ... (process_stratum_target::done_accessing_memory): ... this. (process_target::look_up_symbols): Rename as ... (process_stratum_target::look_up_symbols): ... this. (process_target::supports_read_auxv): Rename as ... (process_stratum_target::supports_read_auxv): ... this. (process_target::read_auxv): Rename as ... (process_stratum_target::read_auxv): ... this. (process_target::supports_z_point_type): Rename as ... (process_stratum_target::supports_z_point_type): ... this. (process_target::insert_point): Rename as ... (process_stratum_target::insert_point): ... this. (process_target::remove_point): Rename as ... (process_stratum_target::remove_point): ... this. (process_target::stopped_by_sw_breakpoint): Rename as ... (process_stratum_target::stopped_by_sw_breakpoint): ... this. (process_target::supports_stopped_by_sw_breakpoint): Rename as ... (process_stratum_target::supports_stopped_by_sw_breakpoint): ... this. (process_target::stopped_by_hw_breakpoint): Rename as ... (process_stratum_target::stopped_by_hw_breakpoint): ... this. (process_target::supports_stopped_by_hw_breakpoint): Rename as ... (process_stratum_target::supports_stopped_by_hw_breakpoint): ... this. (process_target::supports_hardware_single_step): Rename as ... (process_stratum_target::supports_hardware_single_step): ... this. (process_target::stopped_by_watchpoint): Rename as ... (process_stratum_target::stopped_by_watchpoint): ... this. (process_target::stopped_data_address): Rename as ... (process_stratum_target::stopped_data_address): ... this. (process_target::supports_read_offsets): Rename as ... (process_stratum_target::supports_read_offsets): ... this. (process_target::read_offsets): Rename as ... (process_stratum_target::read_offsets): ... this. (process_target::supports_get_tls_address): Rename as ... (process_stratum_target::supports_get_tls_address): ... this. (process_target::get_tls_address): Rename as ... (process_stratum_target::get_tls_address): ... this. (process_target::hostio_last_error): Rename as ... (process_stratum_target::hostio_last_error): ... this. (process_target::supports_qxfer_osdata): Rename as ... (process_stratum_target::supports_qxfer_osdata): ... this. (process_target::qxfer_osdata): Rename as ... (process_stratum_target::qxfer_osdata): ... this. (process_target::supports_qxfer_siginfo): Rename as ... (process_stratum_target::supports_qxfer_siginfo): ... this. (process_target::qxfer_siginfo): Rename as ... (process_stratum_target::qxfer_siginfo): ... this. (process_target::supports_non_stop): Rename as ... (process_stratum_target::supports_non_stop): ... this. (process_target::async): Rename as ... (process_stratum_target::async): ... this. (process_target::start_non_stop): Rename as ... (process_stratum_target::start_non_stop): ... this. (process_target::supports_multi_process): Rename as ... (process_stratum_target::supports_multi_process): ... this. (process_target::supports_fork_events): Rename as ... (process_stratum_target::supports_fork_events): ... this. (process_target::supports_vfork_events): Rename as ... (process_stratum_target::supports_vfork_events): ... this. (process_target::supports_exec_events): Rename as ... (process_stratum_target::supports_exec_events): ... this. (process_target::handle_new_gdb_connection): Rename as ... (process_stratum_target::handle_new_gdb_connection): ... this. (process_target::handle_monitor_command): Rename as ... (process_stratum_target::handle_monitor_command): ... this. (process_target::core_of_thread): Rename as ... (process_stratum_target::core_of_thread): ... this. (process_target::supports_read_loadmap): Rename as ... (process_stratum_target::supports_read_loadmap): ... this. (process_target::read_loadmap): Rename as ... (process_stratum_target::read_loadmap): ... this. (process_target::process_qsupported): Rename as ... (process_stratum_target::process_qsupported): ... this. (process_target::supports_tracepoints): Rename as ... (process_stratum_target::supports_tracepoints): ... this. (process_target::read_pc): Rename as ... (process_stratum_target::read_pc): ... this. (process_target::write_pc): Rename as ... (process_stratum_target::write_pc): ... this. (process_target::supports_thread_stopped): Rename as ... (process_stratum_target::supports_thread_stopped): ... this. (process_target::thread_stopped): Rename as ... (process_stratum_target::thread_stopped): ... this. (process_target::supports_get_tib_address): Rename as ... (process_stratum_target::supports_get_tib_address): ... this. (process_target::get_tib_address): Rename as ... (process_stratum_target::get_tib_address): ... this. (process_target::pause_all): Rename as ... (process_stratum_target::pause_all): ... this. (process_target::unpause_all): Rename as ... (process_stratum_target::unpause_all): ... this. (process_target::stabilize_threads): Rename as ... (process_stratum_target::stabilize_threads): ... this. (process_target::supports_fast_tracepoints): Rename as ... (process_stratum_target::supports_fast_tracepoints): ... this. (process_target::get_min_fast_tracepoint_insn_len): Rename as ... (process_stratum_target::get_min_fast_tracepoint_insn_len): ... this. (process_target::emit_ops): Rename as ... (process_stratum_target::emit_ops): ... this. (process_target::supports_disable_randomization): Rename as ... (process_stratum_target::supports_disable_randomization): ... this. (process_target::supports_qxfer_libraries_svr4): Rename as ... (process_stratum_target::supports_qxfer_libraries_svr4): ... this. (process_target::qxfer_libraries_svr4): Rename as ... (process_stratum_target::qxfer_libraries_svr4): ... this. (process_target::supports_agent): Rename as ... (process_stratum_target::supports_agent): ... this. (process_target::enable_btrace): Rename as ... (process_stratum_target::enable_btrace): ... this. (process_target::disable_btrace): Rename as ... (process_stratum_target::disable_btrace): ... this. (process_target::read_btrace): Rename as ... (process_stratum_target::read_btrace): ... this. (process_target::read_btrace_conf): Rename as ... (process_stratum_target::read_btrace_conf): ... this. (process_target::supports_range_stepping): Rename as ... (process_stratum_target::supports_range_stepping): ... this. (process_target::supports_pid_to_exec_file): Rename as ... (process_stratum_target::supports_pid_to_exec_file): ... this. (process_target::pid_to_exec_file): Rename as ... (process_stratum_target::pid_to_exec_file): ... this. (process_target::supports_multifs): Rename as ... (process_stratum_target::supports_multifs): ... this. (process_target::multifs_open): Rename as ... (process_stratum_target::multifs_open): ... this. (process_target::multifs_unlink): Rename as ... (process_stratum_target::multifs_unlink): ... this. (process_target::multifs_readlink): Rename as ... (process_stratum_target::multifs_readlink): ... this. (process_target::breakpoint_kind_from_pc): Rename as ... (process_stratum_target::breakpoint_kind_from_pc): ... this. (process_target::breakpoint_kind_from_current_state): Rename as ... (process_stratum_target::breakpoint_kind_from_current_state): ... this. (process_target::thread_name): Rename as ... (process_stratum_target::thread_name): ... this. (process_target::thread_handle): Rename as ... (process_stratum_target::thread_handle): ... this. (process_target::supports_software_single_step): Rename as ... (process_stratum_target::supports_software_single_step): ... this. (process_target::supports_catch_syscall): Rename as ... (process_stratum_target::supports_catch_syscall): ... this. (process_target::get_ipa_tdesc_idx): Rename as ... (process_stratum_target::get_ipa_tdesc_idx): ... this.
2020-02-17 16:12:04 +01:00
while (the_target->read_auxv (offset, data, 2 * wordsize) == 2 * wordsize)
{
if (wordsize == 4)
{
uint32_t *data_p = (uint32_t *) data;
if (data_p[0] == match)
{
*valp = data_p[1];
return 1;
}
}
else
{
uint64_t *data_p = (uint64_t *) data;
if (data_p[0] == match)
{
*valp = data_p[1];
return 1;
}
}
offset += 2 * wordsize;
}
return 0;
}
/* See linux-low.h. */
CORE_ADDR
linux_get_hwcap (int wordsize)
{
CORE_ADDR hwcap = 0;
linux_get_auxv (wordsize, AT_HWCAP, &hwcap);
return hwcap;
}
/* See linux-low.h. */
CORE_ADDR
linux_get_hwcap2 (int wordsize)
{
CORE_ADDR hwcap2 = 0;
linux_get_auxv (wordsize, AT_HWCAP2, &hwcap2);
return hwcap2;
}
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
#ifdef HAVE_LINUX_REGSETS
void
initialize_regsets_info (struct regsets_info *info)
{
for (info->num_regsets = 0;
info->regsets[info->num_regsets].size >= 0;
info->num_regsets++)
;
}
#endif
void
initialize_low (void)
{
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
struct sigaction sigchld_action;
Add the target_ops needed for software breakpoints in GDBServer. This patch is in preparation for software breakpoints on ARM linux. It refactors breakpoint and breakpoint_len into breakpoint_kind_from_pc and sw_breakpoint_from kind to prepare the case where we have multiple types of breakpoints. Kind is the type of breakpoint (hardware or software) to be inserted, usually it is the lenght of the software breakpoint but can be something else depending on the target. This patch introduces the linux_target_ops breakpoint_kind_from_pc and sw_breakpoint_from_kind. breakpoint_kind_from_pc returns the breakpoint kind and adjusts the PC to the real memory location in case a flag was present in the PC. E.g the instruction mode on ARM. sw_breakpoint_from_kind returns the software breakpoint for this kind as a string of bytes, the length of the breakpoint is adjusted for the breakpoint's size in memory. For targets that have only one kind of breakpoint, the default value 0 is returned by linux_breakpoint_kind_from_pc so that not all targets need to implement the breakpoint_kind_from_pc operation. No regressions, tested on Ubuntu 14.04 on ARMv7 and x86 With gdbserver-{native,extended} / { -marm -mthumb } Also since the target_ops have been changed compilation was tested on affected archs namely : aarch64, arm, bfin, cris, crisv32, m32r, m68k, mips, nios2, ppc, s390, sparc, tic6x, tile, x86, steins. Not tested : sh gdb/gdbserver/ChangeLog: * linux-aarch64-low.c (aarch64_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-arm-low.c (arm_breakpoint_kind_from_pc): New function. (arm_sw_breakpoint_from_kind): New function. * linux-bfin-low.c (bfin_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-cris-low.c (cris_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-crisv32-low.c (cris_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-low.c (linux_wait_1): Call breakpoint_kind_from_pc and sw_breakpoint_from_kind to increment the pc. (linux_breakpoint_kind_from_pc): New function. (linux_sw_breakpoint_from_kind): New function. (struct target_ops) <sw_breakpoint_from_kind>: Initialize field. (initialize_low): Call breakpoint_kind_from_pc and sw_breakpoint_from_kind to replace breakpoint_data/len. * linux-low.h (struct linux_target_ops) <breakpoint_kind_from_pc>: New field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Likewise. * linux-m32r-low.c (m32r_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-m68k-low.c (m68k_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-mips-low.c (mips_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-nios2-low.c (nios2_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-ppc-low.c (ppc_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-s390-low.c (s390_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-sh-low.c (sh_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-sparc-low.c (sparc_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-tic6x-low.c (tic6x_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-tile-low.c (tile_sw_breakpoint_from_kind): New function. * linux-x86-low.c (x86_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-xtensa-low.c (xtensa_sw_breakpoint_from_kind) New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
2015-10-21 17:17:26 +02:00
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
memset (&sigchld_action, 0, sizeof (sigchld_action));
gdbserver/linux-low: start turning linux target ops into methods This is the beginning of a series of patches that convert the linux low targets into classes derived from linux_process_target. At the end of the series we obtain a class hierarchy that looks like this: process_stratum_target ^ | |-- linux_process_target ^ | |-- x86_target (defined in linux-x86-low) |-- aarch64_target (defined in linux-aarch64-low) |-- ppc_target (defined in linux-ppc-low) |-- ... In several cases, linux_process_target simply forwards a target op request to a corresponding linux_target_ops function. For these cases, the definition in linux_process_target will be removed and the definition will be left to the deriving linux low target class; using inheritance provides a nice and natural, object-oriented simplification in these cases. The series converts linux_target_ops into protected methods of linux_process_target one by one. Throughout the series, based on the needs, static functions defined in linux-low.cc are converted to private methods of linux_process_target as well. This is done either as separate patches or as integrated into a patch that convert a particular linux_target_op into a method. The series ends with the patch titled "gdbserver/linux-low: delete 'linux_target_ops' and 'the_low_target'". Built and regression-tested on x86_64-linux. The following linux low targets have been built (but not tested) via cross-compilation: aarch64, arm, m68k, mips, ppc, riscv, s390, sh, sparc. The other targets (bfin, cris, crisv32, ia64, m32r, nios2, tic6x, tile, xtensa) were neither built nor tested. gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * linux-low.h (the_linux_target): New extern declaration. * linux-low.cc (initialize_low): Use 'the_linux_target' to set 'the_target'. (the_linux_target): Remove. * linux-x86-low.cc (class x86_target): New class. (the_x86_target): New static object. (the_linux_target): Define as pointer to the_x86_target. * linux-aarch64-low.cc (class aarch64_target): New class. (the_aarch64_target): New static object. (the_linux_target): Define as pointer to the_aarch64_target. * linux-arm-low.cc (class arm_target): New class. (the_arm_target): New static object. (the_linux_target): Define as pointer to the_arm_target. * linux-bfin-low.cc (class bfin_target): New class. (the_bfin_target): New static object. (the_linux_target): Define as pointer to the_bfin_target. * linux-cris-low.cc (class cris_target): New class. (the_cris_target): New static object. (the_linux_target): Define as pointer to the_cris_target. * linux-crisv32-low.cc (class crisv32_target): New class. (the_crisv32_target): New static object. (the_linux_target): Define as pointer to the_crisv32_target. * linux-ia64-low.cc (class ia64_target): New class. (the_ia64_target): New static object. (the_linux_target): Define as pointer to the_ia64_target. * linux-m32r-low.cc (class m32r_target): New class. (the_m32r_target): New static object. (the_linux_target): Define as pointer to the_m32r_target. * linux-m68k-low.cc (class m68k_target): New class. (the_m68k_target): New static object. (the_linux_target): Define as pointer to the_m68k_target. * linux-mips-low.cc (class mips_target): New class. (the_mips_target): New static object. (the_linux_target): Define as pointer to the_mips_target. * linux-nios2-low.cc (class nios2_target): New class. (the_nios2_target): New static object. (the_linux_target): Define as pointer to the_nios2_target. * linux-ppc-low.cc (class ppc_target): New class. (the_ppc_target): New static object. (the_linux_target): Define as pointer to the_ppc_target. * linux-riscv-low.cc (class riscv_target): New class. (the_riscv_target): New static object. (the_linux_target): Define as pointer to the_riscv_target. * linux-s390-low.cc (class s390_target): New class. (the_s390_target): New static object. (the_linux_target): Define as pointer to the_s390_target. * linux-sh-low.cc (class sh_target): New class. (the_sh_target): New static object. (the_linux_target): Define as pointer to the_sh_target. * linux-sparc-low.cc (class sparc_target): New class. (the_sparc_target): New static object. (the_linux_target): Define as pointer to the_sparc_target. * linux-tic6x-low.cc (class tic6x_target): New class. (the_tic6x_target): New static object. (the_linux_target): Define as pointer to the_tic6x_target. * linux-tile-low.cc (class tile_target): New class. (the_tile_target): New static object. (the_linux_target): Define as pointer to the_tile_target. * linux-xtensa-low.cc (class xtensa_target): New class. (the_xtensa_target): New static object. (the_linux_target): Define as pointer to the_xtensa_target.
2020-04-02 15:11:23 +02:00
set_target_ops (the_linux_target);
Add the target_ops needed for software breakpoints in GDBServer. This patch is in preparation for software breakpoints on ARM linux. It refactors breakpoint and breakpoint_len into breakpoint_kind_from_pc and sw_breakpoint_from kind to prepare the case where we have multiple types of breakpoints. Kind is the type of breakpoint (hardware or software) to be inserted, usually it is the lenght of the software breakpoint but can be something else depending on the target. This patch introduces the linux_target_ops breakpoint_kind_from_pc and sw_breakpoint_from_kind. breakpoint_kind_from_pc returns the breakpoint kind and adjusts the PC to the real memory location in case a flag was present in the PC. E.g the instruction mode on ARM. sw_breakpoint_from_kind returns the software breakpoint for this kind as a string of bytes, the length of the breakpoint is adjusted for the breakpoint's size in memory. For targets that have only one kind of breakpoint, the default value 0 is returned by linux_breakpoint_kind_from_pc so that not all targets need to implement the breakpoint_kind_from_pc operation. No regressions, tested on Ubuntu 14.04 on ARMv7 and x86 With gdbserver-{native,extended} / { -marm -mthumb } Also since the target_ops have been changed compilation was tested on affected archs namely : aarch64, arm, bfin, cris, crisv32, m32r, m68k, mips, nios2, ppc, s390, sparc, tic6x, tile, x86, steins. Not tested : sh gdb/gdbserver/ChangeLog: * linux-aarch64-low.c (aarch64_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-arm-low.c (arm_breakpoint_kind_from_pc): New function. (arm_sw_breakpoint_from_kind): New function. * linux-bfin-low.c (bfin_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-cris-low.c (cris_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-crisv32-low.c (cris_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-low.c (linux_wait_1): Call breakpoint_kind_from_pc and sw_breakpoint_from_kind to increment the pc. (linux_breakpoint_kind_from_pc): New function. (linux_sw_breakpoint_from_kind): New function. (struct target_ops) <sw_breakpoint_from_kind>: Initialize field. (initialize_low): Call breakpoint_kind_from_pc and sw_breakpoint_from_kind to replace breakpoint_data/len. * linux-low.h (struct linux_target_ops) <breakpoint_kind_from_pc>: New field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Likewise. * linux-m32r-low.c (m32r_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-m68k-low.c (m68k_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-mips-low.c (mips_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-nios2-low.c (nios2_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-ppc-low.c (ppc_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-s390-low.c (s390_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-sh-low.c (sh_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-sparc-low.c (sparc_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-tic6x-low.c (tic6x_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-tile-low.c (tile_sw_breakpoint_from_kind): New function. * linux-x86-low.c (x86_sw_breakpoint_from_kind): New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field. * linux-xtensa-low.c (xtensa_sw_breakpoint_from_kind) New function. (struct linux_target_ops) <breakpoint>: Remove. (struct linux_target_ops) <breakpoint_len>: Remove. (struct linux_target_ops) <breakpoint_kind_from_pc>: Initialize field. (struct linux_target_ops) <sw_breakpoint_from_kind>: Initialize field.
2015-10-21 17:17:26 +02:00
linux_ptrace_init_warnings ();
linux_proc_init_warnings ();
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
sigchld_action.sa_handler = sigchld_handler;
sigemptyset (&sigchld_action.sa_mask);
sigchld_action.sa_flags = SA_RESTART;
sigaction (SIGCHLD, &sigchld_action, NULL);
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
initialize_low_arch ();
Identify remote fork event support This patch implements a mechanism for GDB to determine whether fork events are supported in gdbserver. This is a preparatory patch for remote fork and exec event support. Two new RSP packets are defined to represent fork and vfork event support. These packets are used just like PACKET_multiprocess_feature to denote whether the corresponding event is supported. GDB sends fork-events+ and vfork-events+ to gdbserver to inquire about fork event support. If the response enables these packets, then GDB knows that gdbserver supports the corresponding events and will enable them. Target functions used to query for support are included along with each new packet. In order for gdbserver to know whether the events are supported at the point where the qSupported packet arrives, the code in nat/linux-ptrace.c had to be reorganized. Previously it would test for fork/exec event support, then enable the events using the pid of the inferior. When the qSupported packet arrives there may not be an inferior. So the mechanism was split into two parts: a function that checks whether the events are supported, called when gdbserver starts up, and another that enables the events when the inferior stops for the first time. Another gdbserver change was to add some global variables similar to multi_process, one per new packet. These are used to control whether the corresponding fork events are enabled. If GDB does not inquire about the event support in the qSupported packet, then gdbserver will not set these "report the event" flags. If the flags are not set, the events are ignored like they were in the past. Thus, gdbserver will never send fork event notification to an older GDB that doesn't recognize fork events. Tested on Ubuntu x64, native/remote/extended-remote, and as part of subsequent patches in the series. gdb/gdbserver/ChangeLog: * linux-low.c (linux_supports_fork_events): New function. (linux_supports_vfork_events): New function. (linux_target_ops): Initialize new structure members. (initialize_low): Call linux_check_ptrace_features. * lynx-low.c (lynx_target_ops): Initialize new structure members. * server.c (report_fork_events, report_vfork_events): New global flags. (handle_query): Add new features to qSupported packet and response. (captured_main): Initialize new global variables. * target.h (struct target_ops) <supports_fork_events>: New member. <supports_vfork_events>: New member. (target_supports_fork_events): New macro. (target_supports_vfork_events): New macro. * win32-low.c (win32_target_ops): Initialize new structure members. gdb/ChangeLog: * nat/linux-ptrace.c (linux_check_ptrace_features): Change from static to extern. * nat/linux-ptrace.h (linux_check_ptrace_features): Declare. * remote.c (anonymous enum): <PACKET_fork_event_feature, * PACKET_vfork_event_feature>: New enumeration constants. (remote_protocol_features): Add table entries for new packets. (remote_query_supported): Add new feature queries to qSupported packet. (_initialize_remote): Exempt new packets from the requirement to have 'set remote' commands.
2015-05-12 18:52:41 +02:00
linux_check_ptrace_features ();
}